Index: doc/setup.html =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/doc/setup.html,v retrieving revision 1.10 diff -u -r1.10 setup.html --- doc/setup.html 14 May 2007 15:54:20 -0000 1.10 +++ doc/setup.html 11 Oct 2007 12:38:19 -0000 @@ -36,6 +36,8 @@ Up to calc release R2-6 (synApps release R5_1), the scalcout record needs a fix. (See separate scalcout page.) +Support for the scalcout is optional. StreamDevice works +as well without scalcout or SynApps.

Up to release R3.14.8.2, a fix in EPICS base is required to build @@ -48,15 +50,40 @@

-Make sure that the asyn library and the calc module of -synApps can be found, e.g. by +Make sure that the asyn library (and the calc module of +synApps, if desired) can be found, e.g. by adding ASYN and (if installed) CALC or SYNAPPS to your <top>/configure/RELEASE file: +

 ASYN=/home/epics/asyn/4-5
 CALC=/home/epics/synApps/calc/2-7
 
+

+If you want to enable regular expression matching, you need the PCRE package. +For most Linux systems, it is already installed. In that case add the locations +of the PCRE header and library to your RELEASE file: +

+
+PCRE_INCLUDE=/usr/include/pcre
+PCRE_LIB=/usr/lib
+
+

+If you want to build StreamDevice for platforms without PCRE support, +it is the easiest to build PCRE as an EPICS application. +Download the PCRE package from www.pcre.org +and compile it with my EPICS compatible +Makefile. +Then define the location of the application in your RELEASE file. +

+
+PCRE=/home/epics/pcre
+
+

+Regular expressions are optional. If you don't want them, you don't need this. +

+

For details on <top> directories and RELEASE files, please refer to the Index: src/StreamBuffer.cc =================================================================== RCS file: /afs/psi.ch/user/z/zimoch/.cvsroot/StreamDevice2/src/StreamBuffer.cc,v retrieving revision 1.11 diff -u -r1.11 StreamBuffer.cc --- src/StreamBuffer.cc 11 May 2007 12:39:15 -0000 1.11 +++ src/StreamBuffer.cc 11 Oct 2007 12:06:24 -0000 @@ -60,7 +60,8 @@ // make space for minsize + 1 (for termination) bytes char* newbuffer; long newcap; - if (minsize > 10000) +#ifdef EXPLODE + if (minsize > 1000000) { // crude trap against infinite grow error ("StreamBuffer exploded growing from %ld to %ld chars. Exiting\n", @@ -83,6 +84,7 @@ fprintf(stderr, "\n"); abort(); } +#endif if (minsize < cap) { // just move contents to start of buffer and clear end Index: streamApp/regexp.cmd =================================================================== RCS file: streamApp/regexp.cmd diff -N streamApp/regexp.cmd --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ streamApp/regexp.cmd 11 Oct 2007 12:03:58 -0000 @@ -0,0 +1,12 @@ +#!./streamApp + +dbLoadDatabase "O.Common/streamApp.dbd" +streamApp_registerRecordDeviceDriver + +# no autoconnect for web servers (see regexp.proto) +drvAsynIPPortConfigure web epics.web.psi.ch:80 0 1 + +dbLoadRecords regexp.db + +iocInit +# var streamDebug 1 Index: streamApp/regexp.db =================================================================== RCS file: streamApp/regexp.db diff -N streamApp/regexp.db --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ streamApp/regexp.db 11 Oct 2007 12:03:01 -0000 @@ -0,0 +1,5 @@ +record (stringin, "DZ:regexp") +{ + field (DTYP, "stream") + field (INP, "@regexp.proto readTitle web") +} Index: streamApp/regexp.proto =================================================================== RCS file: streamApp/regexp.proto diff -N streamApp/regexp.proto --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ streamApp/regexp.proto 11 Oct 2007 13:01:16 -0000 @@ -0,0 +1,18 @@ +# regular expression example +# extract the title of from a web page + +outterminator = NL; +interminator = "" NL; # terminators can have arbitrary length + +# Web servers close the connection after sending a page. +# Thus, we can't use autoconnect (see drvAsynIPPortConfigure) +# Handle connection manually in protocol. + +readTitle { + extraInput=ignore; + + connect 1000; # connect to server, 1 second timeout + out "GET http://epics.web.psi.ch/"; # HTTP request + in "%.1/(.*)<\/title>/"; # get string in <title> + disconnect; # servers closes, so do we. +} Index: streamApp/regexp.README =================================================================== RCS file: streamApp/regexp.README diff -N streamApp/regexp.README --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ streamApp/regexp.README 11 Oct 2007 13:06:19 -0000 @@ -0,0 +1,34 @@ +How to use regular expressions in StreamDevice. + +First, you need the PCRE library. +If it is already installed for your (Linux) system (try: rpm -ql pcre), +set the following variables in your RELEASE file: +PCRE_INCLUDE= +PCRE_LIB= + +For vxWorks, Windows and others you're probably out of luck here. +In that case, download the PCRE package from www.pcre.org and +epics.web.psi.ch/software/streamdevice/pcre/Makefile and compile +PCRE as an EPICS application. Use the variable PCRE in your RELEASE file +to define the location of this application. + +If either PCRE or PCRE_INCLUDE or PCRE_LIB are set in the RELEASE file, +StreamDevice is automatically build with regular expression support. + +The syntax is %/regexp/. It can only be used in input. It returns the +next string that matches the regexp. Anything before this string is skipped. + +To use sub-expressions use %.n/rexexp/ where n is a number from 1 to 9 +to match the n-th sub-expression. + +It is possible to limit the input length to the match algorithm like +%m/regexp/ where m is the maximal length. + +Example: +in "%100.1/(.*)<\/title>/"; +This searches the next 100 bytes and returns the string bewteen +<title> and . Any input before is skipped. Any input +after is left in the buffer (and can by matched by other formats). +Note that the / in must be escaped. + +See regexp.cmd, regexp.proto, regexp.db for a working example.