FSCRPX ;SLC/STAFF-NOIS RPC Process ;03/16/2005  08:58
 ;;1.1;NOIS;**2**;Sep 06, 1998
 ;
RPC(OUTPUT,INPUT) ;
 ; routes all NOIS Workstation Calls
 ; ensures user is authorized to use NOIS
 ; input array sent from client should be within a safe partition size
 ; IN and OUT arrays are not being used, param passing uses TMP instead
 
FSCDEV,FIRSTNUM,IN,INLINE,MAX,NUM,OK,OUT,OUTLINE,RTN,START IN,OUT
 
MAX=30 ; max # lines that can be sent to client
 
FSCDEV=1
 
FIRSTNUM=+$O(INPUT(""))
 
INLINE=$G(INPUT(FIRSTNUM))
 
OK=1
 
I $P(INLINE,U,10)=1 D  I 'OK Q  ; 1st input
 
.^TMP("FSCRPC",$J)
 .
SHUTDOWN(INLINE,$G(INPUT(1)),.OK)
 .
'OK D  Q
 
..^TMP("FSCRPC",$J,"OUTPUT",0)="^1"
 
..OUTPUT=$NA(^TMP("FSCRPC",$J,"OUTPUT"))
 .
^TMP("FSCRPC",$J,"INPUT")=INPUT
 
E  D
 
.I $P(INLINE,U,4) D  ; more input being sent
 
..START=$O(^TMP("FSCRPC",$J,"INPUT",""),-1)
 ..
NUM=0 F  S NUM=$O(INPUT(NUM)) Q:NUM<1  D
 
...START=START+1
 ...
^TMP("FSCRPC",$J,"INPUT",START)=INPUT(NUM)
 
INPUT,OUTPUT
 
OUTLINE="^0"
 
OK=1
 
I $E($P(INLINE,U,2),1,6)="FSCRPC" D  I 'OK Q
 
.RTN=$P(INLINE,U,1,2),FSCZZRTN=RTN ;****
 
.'$L($T(@RTN)) S $P(OUTLINE,U,3)=1 Q  ; cancel if invalid routine
 
.I $P(INLINE,U,4) Q  ; don't process until no more input
 
.I $P(INLINE,U,5) MORE(MAX,OUTLINE,.OUTPUTOK=0 Q  ; send more output
 
.^TMP("FSCRPC",$J,"OUTPUT")
 .
RTN=RTN_"(.IN,.OUT)" @RTN
 
.MENUS^FSCRPXM(DUZ,.OUTLINE,INLINE)
 .
^TMP("FSCRPC",$J,"INPUT")
 
OUTLINE=$G(^TMP("FSCRPC",$J,"OUTPUT"))_OUTLINE,^TMP("FSCRPC",$J,"OUTPUT")="" ;*2
 ;I +$G(^TMP("FSCRPC",$J,"OUTPUT"))<MAX D  ;*2
 
+OUTLINE<MAX D  ;*2
 
.^TMP("FSCRPC",$J,"OUTPUT",0)=OUTLINE
 
.OUTPUT=$NA(^TMP("FSCRPC",$J,"OUTPUT"))
 
E  D MORE(MAX,OUTLINE,.OUTPUT)
 
Q
 
;
MORE(MAX,OUTLINE,OUTPUT) ;
 
CNT,COUNT,LINE,NUM
 
^TMP("FSCRPC",$J,"OUTPUTLONG")
 
(CNT,NUM)=0 F  S NUM=$O(^TMP("FSCRPC",$J,"OUTPUT",NUM)) Q:NUM<1  Q:CNT'<MAX  LINE=^(NUMD
 
.CNT=CNT+1
 .
^TMP("FSCRPC",$J,"OUTPUTLONG",CNT)=LINE
 
.^TMP("FSCRPC",$J,"OUTPUT",NUM)
 
I $O(^TMP("FSCRPC",$J,"OUTPUT",0))>0 S $P(OUTLINE,U,5)=1 ; more to come
 
E  S $P(OUTLINE,U,5)=0 ^TMP("FSCRPC",$J,"INPUT"),^TMP("FSCRPC",$J,"OUTPUT")
 
^TMP("FSCRPC",$J,"OUTPUTLONG",0)=OUTLINE
 
OUTPUT=$NA(^TMP("FSCRPC",$J,"OUTPUTLONG"))
 
Q
 
;
SHUTDOWN(INLINE,ONELINE,OK) ; 'OK to shutdown applications
 
MSG,NOW,RTN,VERSION
 
I $P($G(^FSC("PARAM",1,2)),UOK=0 D  Q
 
.^TMP("FSCRPC",$J,"OUTPUT",1)="NOIS server software has been turned off."
 
RTN=$P(INLINE,U,1,2) RTN="ALERTCHK^FSCRPC" Q
 I $L
(RTN)>1 D  I 'OK Q
 
.NOW=$$NOW^XLFDT
 .
I $E($P(RTN,U,2),1,6)'="FSCRPC" D  Q
 
..OK=0
 ..
^XTMP("FSCRPC","##"_RTN_"##",DUZ,NOW)=""
 
.RTN="STARTUP^FSCRPC" D  Q
 
..I $D(^VA(200,"E",1,DUZ)) ^XTMP("FSCRPC","##"_DUZ_"##",NOW)="",OK=0 D  Q  ; this is a menu screen on Forum to restrict NON GOV users
 
...^TMP("FSCRPC",$J,"OUTPUT",1)="You do not have access to NOIS."
 
..^XTMP("FSCRPC","<STARTUP>",-NOW,DUZ)=""
 
..VERSION=ONELINE
 
..^XTMP("FSCRPC","<VERSION>",DUZ)=VERSION
 
..BADVER(VERSION,.OK,.MSG)
 ..
'OK ^TMP("FSCRPC",$J,"OUTPUT",1)=MSG
 
.^(RTN)=1+$G(^XTMP("FSCRPC",RTN))
 .
^(RTN)=1+$G(^XTMP("FSCRPC","ZZUSER",DUZ,RTN))
 
Q
 
;
BADVER(VERSION,OK,MSG) ;
 
SVERSION
 
SVERSION=$P($G(^FSC("PARAM",1,2)),U,7)
 
OK=1,MSG=""
 
'$L(SVERSIONQ
 I 
VERSION["T" VERSION=+VERSION-.01+($P(VERSION,"T",2)*.001)
 
SVERSION'>+VERSION Q
 S 
OK=0
 
MSG=$P($G(^FSC("PARAM",1,3)),U)
 
'$L(MSGMSG="You're software must be updated to "_SVERSION_"."
 
Q