[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
[0050]
[0051]
[0052]
[0053]
[0054]
[0055]
[0056]
[0057]
[0058]
[0059]
[0060]
[0061]
[0062]
[0063]
[0064]
[0065]
[0066]
[0067]
[0068]
[0069]
[0070]
$!-----------------------------------------------------------------------------
$! SINGLEBYTESTREAM.COM
$!
$! Small script to generate a stream of single bytes (as individual records)
$! for testing/demonstrating the server's ability to coalesce these into 'real'
$! records.  Needs to be placed into [CGI-BIN] and then accessed using
$!
$!  /cgi-bin/singlebytestream                 for empty record terminated lines
$!  /cgi-bin/singlebytestream?lf              for <LF> record terminated lines
$!  /cgi-bin/singlebytestream/file/path[?lf]  to return a specific file
$!
$! 24-JAN-2003  MGD  initial
$!-----------------------------------------------------------------------------
$!
$ withlf = 0
$ if WWW_QUERY_STRING .nes. "" then withlf = 1
$ fileName = f$environment("procedure")
$ if WWW_PATH_TRANSLATED .nes. "" then fileName = WWW_PATH_TRANSLATED
$!
$ if f$search(fileName) .eqs. ""
$ then
$    write sys$output "Status: 404"
$    write sys$output ""
$    write sys$output "File ''fileName' not found!"
$    exit
$ endif
$!
$ fileType = f$parse(fileName,,,"type")
$ contentType = "application/octet-stream"
$ if fileType .eqs. ".COM" then contentType = "text/plain"
$ if fileType .eqs. ".GIF" then contentType = "image/gif"
$ if fileType .eqs. ".HTML" then contentType = "text/plain"
$ if fileType .eqs. ".TXT" then contentType = "text/plain"
$!
$ line = "Content-Type: " + contentType 
$ call bout line withlf
$ line = ""
$ call bout line withlf
$!
$ open /read /error=cleanup file 'fileName'
$ readLoop:
$    read /error=readLoopEnd /end=readLoopEnd file line
$    call bout line withlf
$    goto readLoop
$ readLoopEnd:
$!
$ cleanup:
$ close file
$ exit
$!
$!(output the string from the symbol named in P1 one byte/character at a time)
$ bout: subroutine
$ lf[0,8] = 10
$ length = f$length('p1')
$ count = 0
$ byteLoop:
$    if count .eq. length
$    then
$!      (terminate the record)
$       if 'p2'
$          then write sys$output lf
$          else write sys$output ""
$       endif
$       exit
$    endif
$    write sys$output f$extract(count,1,'p1')
$    count = count + 1
$    goto byteLoop
$ endsubroutine
$!-----------------------------------------------------------------------------