/*  Free up queues created by GoServe */

Say "  Free up queues created by SRE-Http (ver 1.2) "
say " "
say "Do NOT run this program if GoServe (using SRE-Http) is still running!"
say "(it is meant to be run AFTER you shut GoServe down) "
say " "
say " What port did you run GoServe on (default=80)"
parse pull aport
if aport="" then aport=80

foo=rxqueue('d','SREF_'||aport||'_VIRTUAL')
say "virtual queue: " foo
foo=rxqueue('d','SREF_'||aport||'_ACCESS')
say "access queue: " foo
foo=rxqueue('d','SREF_'||aport||'_POSTF')
say "POSTFILTER queue: " foo
foo=rxqueue('d','SREF_'||aport||'_USER')
say "USER queue: " foo
foo=rxqueue('d','SREF_'||aport||'_ALIAS')
SAY " ALIAS queue: " FOO
foo=rxqueue('d','SREF_'||aport||'_VARSTORE')
SAY " Varstore queue: " FOO
foo=rxqueue('d','SREF_'||aport||'_PMPRINTF')
SAY " PMPRINTF queue: " FOO


do mm=1 to 40   /* delete too many */
  aname="SREF_"||aport||"_t"||mm
  foo=rxqueue('d',aname)
  say "Remove queue: " aname foo
/*  aname2="\SEM32\SREF_"||aport||"_t"mm
  foo=eventsem_close(aname2)
  say "sem " aname2 foo */
  aname2="\PIPE\_"||aport||"_t"mm
  foo=nmpipe_close(aname2)
  say "Remove pipe " aname2 foo

end /* do */

say "Queue cleanup is done! "

say " Clear macrospace now? "
say "  ...... caution: this might remove procedures used by other programs) ?"
say " Enter 1 for YES, 0 for NO "
parse pull ok
     if ok=1 then do
        foo=macroclear()
        say "  SRE-Http routines removed from macrospace .."
     end  /* Do */

exit


/* -------------------- */
/* get a yes or no , return 1 if yes */
yesno:procedure expose normal reverse bold
parse arg fooa , allopt,altans
if altans<>" " & words(altans)>1 then do
   w1=strip(word(altans,1))
   w2=strip(word(altans,2))
   a1=left(w1,1) ; a2=left(w2,1)
   a1a=substr(w1,2) ; a2a=substr(w2,2)
end
else do
    a1='Y' ; a1a='es'
    a2='N' ; a2a='o'
end  /* Do */
ayn='  '||bold||a1||normal||a1a||'\'||bold||a2||normal||a2a
if allopt=1 then  ayn=ayn||'\'||bold||'A'||normal||'ll'

do forever
 foo1=normal||reverse||fooa||normal||ayn
 call charout,  foo1 normal ':'
 pull anans
 if abbrev(anans,a1)=1 then return 1
 if abbrev(anans,a2)=1 then return 0
 if allopt=1 & abbrev(anans,'A')=1 then return 2
end


