OPEN
"&*/\:?"^prefixes,
1^valid["data"]^valid["indx"]^valid["dict"]^valid["rpt"],
0^pi,
O(*S,%.MACRO),
O(!,*TABLE),
C(*U),
@DOOPEN(A),
@DOOPEN(B),
@DOOPEN(C),
C(!),
END;

DOOPEN
@1^A,
IF{A !L[A_"dir"]^val,
   IF{val 1,
      IF{val$4="$SEG" 1,
         @OPEN;
         N(A_" is not configured here")^#};
      N("unknown db set: "_A)^#,
      1},
   1}

OPEN
!L[A_"dir"]^dircmd,
!L["pkdir"]^pkdircmd,
V(dircmd),
A^lp,
DO{(+!L[lp]^lp)&(lp$L(A)=A)&(pi<L(prefixes)) 1,
   IF{valid[lp'$L(A)] 1,
      @OP(prefixes#pi,lp),
      pi+1^pi}},
V(pkdircmd)

OP
@1^pfx,
@2^what,
N("open "_what_" ("_!L[what]_") on "_pfx)^#,
"O("_pfx_","_!L[what]_")"^opstr,
IF{V(opstr) " ok"^#; " failed"^#}
