home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / RADOOR30.ZIP / ONLINE.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-04-10  |  7.2 KB  |  301 lines

  1. {╔═════════════════════════════════════════════════════════════════════════╗
  2.  ║                                                                         ║
  3.  ║                   (c) CopyRight LiveSystems 1990, 1994                  ║
  4.  ║                                                                         ║
  5.  ║ Author    : Gerhard Hoogterp                                            ║
  6.  ║ FidoNet   : 2:282/100.5   2:283/7.33                                    ║
  7.  ║ BitNet    : GERHARD@LOIPON.WLINK.NL                                     ║
  8.  ║                                                                         ║
  9.  ║ SnailMail : Kremersmaten 108                                            ║
  10.  ║             7511 LC Enschede                                            ║
  11.  ║             The Netherlands                                             ║
  12.  ║                                                                         ║
  13.  ║        This module is part of the RADoor BBS doorwriters toolbox.       ║
  14.  ║                                                                         ║
  15.  ╚═════════════════════════════════════════════════════════════════════════╝}
  16.  
  17. Unit Online;
  18. Interface
  19. Uses GlobInfo,
  20.      BBStypes,
  21.      LowLevel,
  22.      Fossil;
  23.  
  24. Type ChkFunc = Function:Boolean;
  25.      GetProc = Procedure(Foss : FossilObject);
  26.      PutProc = Procedure(ToNode : Byte;Msg : String);
  27.  
  28. Var ChkForMsg : ChkFunc;
  29.     ReadMsg   : GetProc;
  30.     WriteMsg  : PutProc;
  31.  
  32.  
  33.  
  34. Implementation
  35. {$F+}
  36.  
  37. Const ReadOnly           = $00;
  38.       WriteOnly          = $01;
  39.       ReadWrite          = $02;
  40.  
  41.       ShareCompatible    = $00;
  42.       ShareDenyReadWrite = $10;
  43.       ShareDenyWrite     = $20;
  44.       ShareDenyRead      = $30;
  45.       ShareDenyNone      = $40;
  46.  
  47.       Inheritance        = $80;
  48.  
  49. {---- RA Online message procedures ----------------------------------------}
  50.  
  51. Function RAChkForMsg:Boolean;
  52. Var NodeNr : String[2];
  53.     MsgName: String[12];
  54.  
  55. Begin
  56. RAChkForMsg:=false;
  57. If GlobalInfo.UseQuietMode
  58.    Then Exit;
  59. NodeNr:=S(GlobalInfo.Node,0);
  60. MsgName:='NODE'+NodeNr+'.RA';
  61. RAChkForMsg:=ExistFile(GlobalInfo.CommonDir+MsgName);
  62. End;
  63.  
  64. Procedure RAReadMsg(Foss : FossilObject);
  65. Var Msg    : Text;
  66.     NodeNr : String[2];
  67.     MsgName: String[12];
  68.     Line   : String[80];
  69.     Count  : Byte;
  70. Begin
  71. NodeNr:=S(GlobalInfo.Node,0);
  72. MsgName:='NODE'+NodeNr+'.RA';
  73.  
  74. FileMode:=ReadOnly+ShareDenyNone;
  75. Assign(Msg,GlobalInfo.CommonDir+MsgName);
  76. Reset(Msg);
  77.  
  78. While Not Eof(Msg) Do
  79.  Begin
  80.  ReadLn(Msg,Line);
  81.  If Pos(']258',Line)=0
  82.     Then Begin
  83.          Count:=1;
  84.          While Count<Length(Line) Do
  85.           Begin
  86.           If Line[Count]=#11
  87.              Then Delete(Line,Count,1)
  88.              Else Inc(Count);
  89.            End;
  90.          {$IfDef MultiLanguage}
  91.            Foss.WriteLnF(#13'^0'+Line);
  92.          {$Else}
  93.            Foss.WriteLnF(#13+Line);
  94.          {$EndIf}
  95.          End;
  96.  End;
  97. Close(Msg);
  98. Erase(Msg);
  99. If IoResult<>0
  100.    Then;
  101. End;
  102.  
  103. Procedure RASendOnlineMsg( ToNode  : Byte;
  104.                            Msg     : String);
  105.  
  106. Var MsgF    : Text;
  107.     NodeNr  : String[2];
  108.     MsgName : String[12];
  109.  
  110. Begin
  111. NodeNr:=S(ToNode,0);
  112. MsgName:='NODE'+NodeNr+'.RA';
  113.  
  114. FileMode:=ReadWrite+ShareDenyReadWrite;
  115. Assign(MsgF,GlobalInfo.CommonDir+MsgName);
  116. Append(MsgF);
  117. If IoResult<>0
  118.    Then Rewrite(MsgF);
  119. {$IfDef MultiLanguage}
  120.   WriteLn(MsgF,#11+']497'+GlobalInfo.UserName+#11+']496'+S(GlobalInfo.Node,0)+':');
  121. {$Else}
  122.   WriteLn(MsgF,'*** MSG *** From '+GlobalInfo.UserName+' on node '+S(GlobalInfo.Node,0)+':');
  123. {$EndIf}
  124. WriteLn(MsgF,'');
  125. WriteLn(MsgF,Msg);
  126. WriteLn(MsgF,'');
  127. WriteLn(MsgF,#11']258'#01);
  128.  
  129. Close(MsgF);
  130. End;
  131.  
  132. {---- QBBS Online message procedures ----------------------------------------}
  133.  
  134. Function QChkForMsg:Boolean;
  135. Var NodeNr : String[2];
  136.     MsgName: String[12];
  137.  
  138. Begin
  139. QChkForMsg:=false;
  140. If GlobalInfo.UseQuietMode
  141.    Then Exit;
  142. NodeNr:=S(GlobalInfo.Node,2);
  143. If NodeNr[1]=' '
  144.    Then NodeNr[1]:='0';
  145. MsgName:='NODE'+NodeNr+'.DAT';
  146. QChkForMsg:=ExistFile(GlobalInfo.CommonDir+MsgName);
  147. End;
  148.  
  149. Procedure QReadMsg(Foss : FossilObject);
  150. Var Msg    : Text;
  151.     NodeNr : String[2];
  152.     MsgName: String[12];
  153.     Line   : String[80];
  154. Begin
  155. NodeNr:=S(GlobalInfo.Node,2);
  156. If NodeNr[1]=' '
  157.    Then NodeNr[1]:='0';
  158. MsgName:='NODE'+NodeNr+'.DAT';
  159.  
  160. FileMode:=ReadOnly+ShareDenyNone;
  161. Assign(Msg,GlobalInfo.CommonDir+MsgName);
  162. Reset(Msg);
  163.  
  164. While Not Eof(Msg) Do
  165.  Begin
  166.  ReadLn(Msg,Line);
  167.  Foss.WriteLnF(#13+Line);
  168.  End;
  169. Close(Msg);
  170. Erase(Msg);
  171. If IoResult<>0
  172.    Then;
  173. End;
  174.  
  175. Procedure QSendOnlineMsg( ToNode  : Byte;
  176.                           Msg     : String);
  177.  
  178. Var MsgF    : Text;
  179.     NodeNr  : String[2];
  180.     MsgName : String[12];
  181.  
  182. Begin
  183. NodeNr:=S(ToNode,2);
  184. If NodeNr[1]=' '
  185.    Then NodeNr[1]:='0';
  186. MsgName:='NODE'+NodeNr+'.DAT';
  187.  
  188. FileMode:=ReadWrite+ShareDenyReadWrite;
  189. Assign(MsgF,GlobalInfo.CommonDir+MsgName);
  190. Append(MsgF);
  191. If IoResult<>0
  192.    Then Rewrite(MsgF);
  193.  
  194. WriteLn(MsgF,'Message ** from '+GlobalInfo.UserName+' on node '+S(GlobalInfo.Node,0)+':');
  195. WriteLn(MsgF,'');
  196. WriteLn(MsgF,Msg);
  197. WriteLn(MsgF,'');
  198. WriteLn(MsgF,^A);
  199.  
  200. Close(MsgF);
  201. End;
  202.  
  203. {---- SBBS Online message procedures ----------------------------------------}
  204.  
  205. Function SBBSChkForMsg:Boolean;
  206. Var NodeNr : String[2];
  207.     MsgName: String[12];
  208.  
  209. Begin
  210. SBBSChkForMsg:=false;
  211. If GlobalInfo.UseQuietMode
  212.    Then Exit;
  213. NodeNr:=S(GlobalInfo.Node,0);
  214. MsgName:='TOLINE'+NodeNr;
  215. SBBSChkForMsg:=ExistFile(GlobalInfo.CommonDir+MsgName);
  216. End;
  217.  
  218. Procedure SBBSReadMsg(Foss : FossilObject);
  219. Var Msg    : Text;
  220.     Name   : String[40];
  221.     NodeNr : String[2];
  222.     MsgName: String[12];
  223.     Line   : String[80];
  224. Begin
  225. NodeNr:=S(GlobalInfo.Node,1);
  226. MsgName:='TOLINE'+NodeNr;
  227.  
  228. FileMode:=ReadOnly+ShareDenyNone;
  229. Assign(Msg,GlobalInfo.CommonDir+MsgName);
  230. Reset(Msg);
  231.  
  232. While Not Eof(Msg) Do
  233.  Begin
  234.  ReadLn(Msg,Line);
  235.  If Pos('/MESSAGE',Line)>0
  236.     Then Begin
  237.          Name:=FindToken(Line,',');
  238.          Name:=FindToken(Line,',');
  239.          NodeNr:=FindToken(Line,'/');
  240.          WriteLn('*** An online message from ',Name,' on node ',NodeNr,':');
  241.          End
  242.     Else Begin
  243.          If Line[1]<>'/'
  244.             Then Foss.WriteLnF(Line);
  245.          End;
  246.  End;
  247. Close(Msg);
  248. Erase(Msg);
  249. If IoResult<>0
  250.    Then;
  251. End;
  252.  
  253. Procedure SBBSSendOnlineMsg( ToNode  : Byte;
  254.                              Msg     : String);
  255.  
  256. Var MsgF    : Text;
  257.     NodeNr  : String[2];
  258.     MsgName : String[12];
  259.  
  260. Begin
  261. NodeNr:=S(GlobalInfo.Node,0);
  262. MsgName:='TOLINE'+NodeNr;
  263.  
  264. FileMode:=ReadWrite+ShareDenyReadWrite;
  265. Assign(MsgF,GlobalInfo.CommonDir+MsgName);
  266. Append(MsgF);
  267. If IoResult<>0
  268.    Then Rewrite(MsgF);
  269.  
  270. WriteLn(MsgF,'/MESSAGE,',GlobalInfo.UserName,',',S(GlobalInfo.Node,0),'/');
  271. WriteLn(MsgF,'');
  272. WriteLn(MsgF,Msg);
  273. WriteLn(MsgF,'');
  274. WriteLn(MsgF,'/END/');
  275.  
  276. Close(MsgF);
  277. End;
  278.  
  279. Begin
  280.  
  281. Case CurrentBBSType Of
  282.  NO_BBS,
  283.  RA_BBS : Begin
  284.           ChkForMsg:=RAChkForMsg;
  285.           ReadMsg:=RAReadMsg;
  286.           WriteMsg:=RASendOnlineMsg;
  287.           End;
  288.  Q_BBS  : Begin
  289.           ChkForMsg:=QChkForMsg;
  290.           ReadMsg:=QReadMsg;
  291.           WriteMsg:=QSendOnlineMsg;
  292.           End;
  293.  S_BBS  : Begin
  294.            ChkForMsg:=SBBSChkForMsg;
  295.           ReadMsg:=SBBSReadMsg;
  296.           WriteMsg:=SBBSSendOnlineMsg;
  297.           End;
  298. End; {Case}
  299.  
  300. End.
  301.