Patch title: Release 94 bulk changes
Abstract:
File: /pliant/protocol/lpr/embedded.pli
Key:
    Removed line
    Added line
module "/pliant/language/unsafe.pli"
module "/pliant/language/stream.pli"
module "/pliant/admin/file.pli"
module "/pliant/fullpliant/this_computer.pli"
module "database.pli"


function lpr_embedded_configure root
  arg Str root
  (var Stream s) open root+"etc/printcap" out+safe
  each printer this_computer:env:"printer"
    # FIXME: walk around Unix bug when keyof:printer=""
    file_tree_delete root+"var/spool/"+keyof:printer+"/"
    file_tree_create root+"var/spool/"+keyof:printer+"/"
    file_rights root+"var/spool/"+keyof:printer+"/" undefined undefined 511 0
    s writeline (shunt printer:"default"="true" "lp|" "")+keyof:printer+":\"
    s writeline "  :sd=/var/spool/"+keyof:printer+"/:\"
    s writeline "  :mx#0:\"
    s writeline "  :sh:"
  s close


function lpr_embedded_convert control job
  arg Str control ; arg_rw Data:LprJob job
  (var Stream s) open control in+safe
  while not s:atend
    var Str l := s readline
    if (l eparse "J" any:(var Str remain))
      job label := remain
    if (l eparse "N" any:(var Str remain))
      job file := remain


gvar Sem embedded_sem

function lpr_embedded_migrate root
  arg Str root
  embedded_sem request
  each printer this_computer:env:"printer"
    var Str path := root+"var/spool/"+keyof:printer+"/"
    if (file_query path+".seq" standard)=defined
      file_delete path+".seq"
    var Array:FileInfo files := file_list path standard+relative
    for (var Int i) 0 files:size-1
      if (files:i:name parse "d" any:(var Str remain))
        var Str id := generate_id
        lpr_database:data:job create id
        var Data:LprJob job :> lpr_database:data:job id
        job queue := keyof printer
        job s_startup := datetime
        lpr_embedded_convert path+"c"+remain job
        file_delete path+"c"+remain
        file_tree_create "data:/pliant/spool/"+keyof:printer+"/"
        if (file_move path+files:i:name "data:/pliant/spool/"+keyof:printer+"/"+id+".lpr")=success
          job s_status := "T"
        else
          lpr_database:data:job delete id
  embedded_sem release

      
export lpr_embedded_configure lpr_embedded_convert lpr_embedded_migrate