source: WorldVistAEHR/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XUSC1S.m@ 1361

Last change on this file since 1361 was 613, checked in by George Lilly, 15 years ago

initial load of WorldVistAEHR

File size: 3.2 KB
Line 
1XUSC1S ;ISCSF/RWF - Interface to Server services. ;10/09/2002 16:59
2 ;;8.0;KERNEL;**283**;Jul 10, 1995
3 Q
4 ;XUSC is used to pass data around.
5 ; 5224 is the standard VA port for the Services Server.
6LISTEN ;only for OpenM
7 S $ETRAP="D ^%ZTER H"
8 D LISTEN^%ZISTCPS(5500,"ONT^XUSC1S")
9 Q
10DSM ;Test listener
11 S IO=% O IO:(SHARE) U IO ;Setup TCP port
12 S IO(0)="_NLA0:" O IO(0) ;Setup null device
13 D SVR
14 Q
15MSM ;Entry point from MSERVER
16 S IO=56,IO(0)=46 O 46 ;Null device
17 D SVR C IO
18 Q
19ONT ;Cache/OpenM
20 S IO=$I,IO(0)="//./nul" O IO(0)
21 D SVR
22 Q
23 ;
24SVR ;Entry point when we have a connect
25 ;See that IO=TCP device, and IO(0) is Null device and Open.
26 N XUSC11,XUSCER,XUSCEXIT,XUSCCMD,XUSCDAT,ZTQUEUED D SETUP
27 N $ESTACK,$ETRAP S $ETRAP="D ^%ZTER H"
28 K ^XUTL("XQ",$J) S ^XUTL("XQ",$J,0)=$$NOW^XLFDT
29 F D CREAD Q:XUSCEXIT D Q:XUSCEXIT
30 . I XUSCCMD="" S XUSC11("TCNT")=$G(XUSC11("TCNT"))+1 S:$$STOP!(XUSC11("TCNT")>10) XUSCEXIT=1 Q
31 . I XUSCCMD'?4A D SEND("500 Bad CMD: "_$E(XUSCCMD,1,20)) Q
32 . I $T(@XUSCCMD)="" D SEND("500 ") Q
33 . S XUSC11("TCNT")=0
34 . D @XUSCCMD I $G(XUSCER) D TRACE("ERROR: "_XUSCER)
35 . Q
36 S:XUSCEXIT IO("C")=1
37 I '$G(XUSCDBUG) K ^TMP("XUSCI",$J),^TMP("XUSCO",$J) ;Clean up
38 D TRACE("Exit")
39 Q
40HELO ;Process HELO
41 S XUSC11("SITE")=$P(XUSCDAT," ")
42 ;Do any check on who is sending
43 D SEND("220 "_$$KSP^XUPARAM("WHERE")_" Ready for "_XUSCDAT)
44 Q
45 ;
46NOOP ;
47 D SEND("250 OK")
48 Q
49 ;
50DATA ;Process DATA
51 ; The DATA cmd can pass some parameters as well, this could be passed
52 ; to the processing routine also.
53 N XUSCRTN,P,I,DUZ S DUZ=0,DUZ(0)="@"
54 D TRACE("Get Data")
55 S (XUSCRTN,XUSC11("DATA"))=XUSCDAT K @XUSCIN,@XUSCOUT
56 D DATA^XUSC1S1(XUSCIN,.XUSC11)
57 S P="" F I=1:1 Q:'$D(XUSC11("P"_I)) S P=P_"P"_I_"="_XUSC11("P"_I)_", "
58 D TRACE("PARAM "_P)
59 ;Use the Null Device
60 U IO(0)
61 ;Now call soneone to process the data
62 ;I XUSC11("P1")="SERVER" D SERVER^XUSC1S2
63 I XUSC11("P1")="PING" M @XUSCOUT=@XUSCIN
64 U IO ;Back to the TCP device
65 Q
66TURN ;Turn and send responce
67 D SEND("220 OK")
68 D SDATA^XUSC1S1(XUSCOUT,XUSC11("P1"))
69 D CREAD,TRACE("Data Sent ") ;Look for 220 ok
70 Q
71QUIT ;Process QUIT
72 D TRACE("QUIT")
73 S XUSCMSG="",XUSCEXIT=1
74 Q
75 ;
76CREAD ;Read a string
77 N $ETRAP S $ETRAP="S $EC="""" G CREX"
78 N I S (Y,XUSCDAT,XUSCCMD)="",XUSCER=0
79 F I=0:1:255 R X#1:XUSCTIME S:'$T XUSCER=1 D TRACE("Char "_$A(X)) Q:X=$C(10)!XUSCER S Y=Y_X
80 S Y=$TR(Y,$C(13,10)),XUSCCMD=$P(Y," "),XUSCDAT=$P(Y," ",2,99)
81 D TRACE("Cmd Read "_Y)
82 Q
83CREX S XUSCEXIT=1,XUSCER="1 Error"
84 D TRACE("CREAD error: "_$$EC^%ZOSV_" Y="_Y)
85 Q
86 ;
87SEND(MSG) ;Send a cmd MSG
88 N $ETRAP S $ETRAP="S $EC="""" D CREX"
89 D TRACE("Cmd Send "_MSG)
90 W MSG,$C(13,10),!
91 Q
92 ;
93SETUP ;Setup needed variables
94 K IO("C") S (XUSCER,XUSCEXIT)=0,XUSCTIME=345,ZTQUEUED=.5 ;**** CHANGE BACK
95 S XUSCTRC="S: ",XUSC11("P1")="TEXT"
96 S XUSCIN=$NA(^TMP("XUSCI",$J)),XUSCOUT=$NA(^TMP("XUSCO",$J))
97 S XUSCDBUG=$$GET^XPAR("SYS","XUSC1 DEBUG",,"Q")
98 D TRACE(-1),TRACE("Server Setup")
99 Q
100STOP(%) ;Should the server stop.
101 I $G(%)=1 S ^TMP("XUSC1","STOP")=1 Q
102 I $G(%)=-1 K ^TMP("XUSC1","STOP") Q
103 I $D(^TMP("XUSC1","STOP")) Q 1
104 Q 0
105 ;
106TRACE(S1) ;
107 N H,%
108 I S1=-1 K ^TMP("XUSC1",$J) Q
109 Q:'$G(XUSCDBUG)
110 S H=$P($H,",",2),H=(H\3600)_":"_(H#3600\60)_":"_(H#60)_" "
111 L +^TMP("XUSC1",$J)
112 S %=$G(^TMP("XUSC1",$J,0))+1,^(0)=%,^(%)=H_$G(XUSCTRC)_S1
113 L -^TMP("XUSC1",$J)
114 Q
115 ;
Note: See TracBrowser for help on using the repository browser.