aboutsummaryrefslogtreecommitdiff
path: root/noao/obsutil/src/doc/cgiparse.hlp
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /noao/obsutil/src/doc/cgiparse.hlp
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'noao/obsutil/src/doc/cgiparse.hlp')
-rw-r--r--noao/obsutil/src/doc/cgiparse.hlp166
1 files changed, 166 insertions, 0 deletions
diff --git a/noao/obsutil/src/doc/cgiparse.hlp b/noao/obsutil/src/doc/cgiparse.hlp
new file mode 100644
index 00000000..f054ca4e
--- /dev/null
+++ b/noao/obsutil/src/doc/cgiparse.hlp
@@ -0,0 +1,166 @@
+.help cgiparse Mar03 noao.obsutil
+.ih
+NAME
+cgiparse -- parse STRING_QUERY environment var. into parameters
+.ih
+SYNOPSIS
+CGIPARSE parses the STRING_QUERY environment varabile and sets parameters.
+The string format is a list of task.param=value pairs which includes the
+standard QUERY string special characters '&', '+', and '%'. This is
+intended to parse a query from a CGI script.
+.ih
+USAGE
+cgiparse
+.ih
+PARAMETERS
+There are no parameters. The input is the value of the QUERY_STRING
+environment variable.
+.ih
+DESCRIPTION
+CGIPARSE parses the STRING_QUERY environment varabile and sets parameters.
+The string format is a list of task.param=value pairs which includes the
+standard QUERY string special characters '&', '+', and '%'. This is
+intended to parse a query from a CGI script.
+
+The only input is the STRING_QUERY variable. If it is undefined the
+task simply does nothing. The string will normally use the standard
+parameters for this type of string. The data fields are task.param=value
+strings. As each is parsed the values will be set for the task. This
+assumes the tasks are defined. Theere is no error checking for
+undefined tasks or parameters.
+.ih
+EXAMPLES
+1. A CGI script calls a CL script with the STRING_QUERY string set.
+The string has "imheader.longheader=yes". CGIPARSE is called and
+when it completes the parameter value is set.
+
+.nf
+ cl> lpar imhead
+ cl> lpar imheader
+ images = image names
+ (imlist = "*.imh,*.fits,*.pl,*.qp,*.hhh") default image ...
+ (longheader = no) print header in multi-line format
+ (userfields = yes) print the user fields ...
+ (mode = "ql")
+ cl> cgiparse
+ cl> lpar imheader
+ images = image names
+ (imlist = "*.imh,*.fits,*.pl,*.qp,*.hhh") default image ...
+ (longheader = yes) print header in multi-line format
+ (userfields = yes) print the user fields ...
+ (mode = "ql")
+.fi
+
+Note that when running this in a "#!cl" script where the "login.cl" is
+not used that you must be careful to have all tasks referenced by the
+query string defined.
+
+2. Below is a "#!cl" type script that uses CGIPARSE. It is used for
+a spectral exposure time calculator based on OBSUTIL.SPTIME though many
+aspects are fairly generic for this type of application.
+
+.nf
+#!/iraf/iraf/bin.freebsd/cl.e -f
+
+file urldir
+
+# The following must be set for different hosts.
+# The home directory and the urldir are the same but in different syntax.
+# The home directory must have a world writable tmp subdirectory.
+
+set arch = ".freebsd"
+set (home = osfn ("/www/htdocs/noao/staff/brooke/gsmt/"))
+urldir = "/noao/staff/brooke/gsmt/"
+
+# The uparm is a unique temporary directory.
+s1 = mktemp ("uparm") // "/"
+set (uparm = "home$/tmp/" // s1)
+mkdir uparm$
+cd uparm
+printf ("!/bin/chmod a+rw %s\n", osfn("uparm$")) | cl
+
+# The URL directory is the same as uparm.
+urldir = urldir // "tmp/" // s1
+
+# A private graphcap is required to give an path for sgidispatch.
+set graphcap = home$graphcap
+
+# Load packages.
+dataio
+proto
+noao
+onedspec
+spectime
+gsmt
+
+# Parse the CGI string and set parameters.
+cgiparse
+
+# Create the output.
+
+# Start HTML.
+printf ("Content-Type: text/html\n\n")
+printf ("<html><head><title>Test</title></head>\n")
+printf ("<body>\n")
+if (cl.line == "...")
+ printf ("<center><h2>SPECTIME</h2></center>\n", cl.line)
+else
+ printf ("<center><h2>%s</h2></center>\n", cl.line)
+printf ("<pre>\n")
+
+# Execute task(s).
+#show QUERY_STRING
+
+setup interactive=no mode=h
+printf ("</pre>\n")
+printf ("<A Href='http://www.noao.edu/noao/staff/brooke/gsmt/gsmt.php?stage=1'>Back to form</A>")
+printf ("<pre>\n")
+
+sptime output="counts,snr" graphics="g-gif" interactive=no mode=h
+
+printf ("</pre>\n")
+printf ("<A Href='http://www.noao.edu/noao/staff/brooke/gsmt/gsmt.php?stage=1'>Back to form</A>\n")
+
+printf ("<pre>\n")
+
+# Add any gifs created. We have to wait for them to be created.
+
+gflush
+
+i = 0; j = 1
+while (i != j) {
+ sleep 2
+ j = i
+ files *.gif | count STDIN | scan (i)
+}
+
+
+if (i > 0) {
+ printf ("<br><p><em>Note: DN and S/N are per-pixel</em><br>\n")
+
+ files *.gif > gifs
+ list = "gifs"
+ while (fscan (list, s1) != EOF) {
+ if (access (s1))
+ printf ("<img src=\"%s%s\">\n", urldir, s1)
+ }
+ list = ""
+ ## delete ("uparm$gifs", verify-)
+}
+
+printf ("</pre>\n")
+
+# Finish HTML.
+
+printf ("<A Href='http://www.noao.edu/noao/staff/brooke/gsmt/gsmt.php?stage=1'>Back to form</A>")
+
+printf ("</body></html>\n")
+
+# Clean up.
+## delete ("*[^g][^i][^f]", verify-)
+
+logout
+.fi
+.ih
+SEE ALSO
+.endhelp