#!/bin/sh
# the next line restarts using wish \
exec tclsh "$0" "$@"

# SET the paths to the package libraries which are used 

source [ file join $env(TCLTOOLS_HOME) TclToolInits.tcl ]
TclToolInits UTILS UDF UDFDB GUI
                                                                                
lappend auto_path [file join $env(UDFTOOL_HOME) Client]
package require Client
package require http

# wm withdraw .
# GUIprefsRead

# THIS is the request packet - genereally written out by a routine in the
#   UDF kernel

if [string match window* $tcl_platform(platform)] {
    set InfoPacket [file join $env(UDFTOOL_HOME) bin .PrOmOtEuDf]
} else { set InfoPacket ".PrOmOtEuDf" }

# IF set use the time out for UDFLibrarian

TUreadUDFrc udfLibrarian udfRc
if [info exists udfRc(TmOut)] {
    set TmOut $udfRc(TmOut)
} else { set TmOut 15000 }

# READ the request information packet.  For UDF data it has the form
#
#   REQUEST    : SEARCH
#   PROJECT    : UDF PROJECT ACRONYM
#   MISSION    : UDF MISSION ACRONYM
#   EXPERIMENT : UDF EXPERIMENT ACRONYM
#   INSTRUMENT : UDF INSTRUMENT ACRONYM
#   VIRTUAL    : UDF VIRTUAL ACRONYM
#   BEG YEAR   : START YEAR
#   BEG DOY    : START DOY
#   BEG MSEC   : START MILLISECOND
#   END YEAR   : END YEAR
#   END DOY    : END DOY
#   END MSEC   : END MILLISECOND
#   STATUS     : POPUP INFORMATION WINDOW OPTION

set pList [CLreqfileRead $InfoPacket ]
if { [llength pList] > 0 } {

# DO the promote depending on what is being requested

   switch -exact -- [lindex $pList 0 ] {
      SEARCH   { CLhdPromote $pList $TmOut }
      SEARCHV  { CLvPromote $pList $TmOut }
      SEARCHP  { CLpPromote $pList $TmOut }
      PKGNAMES { CLsPromote $pList $TmOut }
      PKGSEND  { CLsPromote $pList $TmOut }
   }

#  destroy .
}
