home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / netcraft / netserv.pas < prev    next >
Pascal/Delphi Source File  |  1988-06-10  |  9KB  |  341 lines

  1. {*********************************************************************
  2.  
  3.   NETSERV - A unit of NetWare Application Program Interfaces
  4.             Relating to File Server Services
  5.             for Turbo Pascal 4.0 and Advanced NetWare (any verison)
  6.  
  7.   Copyright (c) 1988, Richard S. Sadowsky
  8.   All rights reserved
  9.  
  10.   version .7 6/10/88 by Richard S. Sadowsky 74017,1670
  11.  
  12. **********************************************************************}
  13. Unit NetServ;
  14. {$I-,V-,S+,R+}
  15.  
  16. interface
  17.  
  18. uses DOS;
  19.  
  20. type
  21.   DayOfTheWeek     = (Sunday,Monday,Tuesday,Wednesday,Thursday,
  22.                       Friday,Saturday);
  23.  
  24. var
  25.   NovRegs          : Registers; { register type for DOS/Novell calls }
  26.  
  27. const
  28.   { error return codes for AttachToServer }
  29.   ALREADY_ATTACHED = $F8;  { already attached to server }
  30.   NO_FREE_SLOTS    = $F9;  { No free connection slots at server }
  31.   NO_SERVER        = $FF;  { No response from server }
  32.  
  33. procedure GetServerDateTime(var Year,Month,Day,Hour,Minute,Second : Word;
  34.                             var WeekDay : DayOfTheWeek);
  35.  
  36. function DisableServerLogin : Boolean;
  37. { returns true if file server login is successfully disabled }
  38. { THIS FUNCTION DISABLES ALL LOGINS TO A SERVER FROM ANY WORKSTATION }
  39. { Use EnableServerLogin to enable (must be called from same WS) }
  40.  
  41. function EnableServerLogin : Boolean;
  42. { returns true if file server login is successfully enabled }
  43. { Use DisableServerLogin to disable (must be called from same WS }
  44.  
  45. function DownFileServer(ForceItDown : Boolean) : Byte;
  46. {
  47.   DOWNS the server!!!
  48.   Warning, this function will really down your file server kiddo!
  49.   If ForceItDown is TRUE, it will down the server EVEN IF FILES ARE OPEN!!!
  50. }
  51.  
  52. function ServerCopy(Source,Dest : Word; SOff,DOff,NoBytes : LongInt;
  53.                     var NoBytesCopied : LongInt) : Byte;
  54.  
  55. function GetLoginStatus(var LoginEnabled : Boolean) : Byte;
  56. { if Login is enabled then returns TRUE in LoginEnabled }
  57. { return byte
  58.   00h  - Success
  59.   C6h No Console Rights
  60. }
  61.  
  62. procedure PurgeAllErased;
  63. { actually delete all deleted files from server }
  64.  
  65. procedure PurgeErased;
  66. { delete only files deleted by requesting WS from server }
  67.  
  68. function AttachToServer(ServerConnID : Byte) : Byte;
  69. { Create an attachment between a server and a workstation }
  70. { Does not Login the workstation }
  71.  
  72. function DetachFromServer(ServerConnID : Byte) : Byte;
  73. { this functions logs the object out, and detaches the workstation from }
  74. { the file server. }
  75.  
  76. implementation
  77.  
  78. function MakeLong(HiWord,LoWord : Word) : LongInt;
  79. {takes hi and lo words and makes a longint }
  80. Inline(
  81.   $58/    { pop ax ; pop low word into AX }
  82.   $5A);   { pop dx ; pop high word into DX }
  83.  
  84. procedure GetServerDateTime(var Year,Month,Day,Hour,Minute,Second : Word;
  85.                             var WeekDay : DayOfTheWeek);
  86. type
  87.   ReplyBuffer      = array[1..10] of Byte;
  88.  
  89. var
  90.   Reply            : ReplyBuffer;
  91.  
  92. begin
  93.   with NovRegs do begin
  94.     AX := $E700;
  95.     DS := Seg(Reply);
  96.     DX := Ofs(Reply);
  97.   end; {with}
  98.   MsDos(NovRegs);
  99.   Year    := Word(Reply[1]) + 1900;
  100.   Month   := Word(Reply[2]);
  101.   Day     := Word(Reply[3]);
  102.   Hour    := Word(Reply[4]);
  103.   Minute  := Word(Reply[5]);
  104.   Second  := Word(Reply[6]);
  105.   WeekDay := DayOfTheWeek(Reply[7]);
  106. end;
  107.  
  108. function DisableServerLogin : Boolean;
  109. { returns true if file server login is successfully disabled }
  110. { THIS FUNCTION DISABLES ALL LOGINS TO A SERVER FROM ANY WORKSTATION }
  111. { Use EnableServerLogin to enable (must be called from same WS) }
  112. var
  113.   Reply            : Word;
  114.   Request          : Record
  115.                        Len  : Word;
  116.                        SubF : Byte;
  117.                      end;
  118.  
  119. begin
  120.   Reply := 0;
  121.   with Request do begin
  122.     Len  := 1;
  123.     SubF := $CB;
  124.   end;
  125.   with NovRegs do begin
  126.     AX := $E300;
  127.     DS := Seg(Request);
  128.     SI := Ofs(Request);
  129.     ES := Seg(Reply);
  130.     DI := Ofs(Reply);
  131.     MsDos(NovRegs);
  132.     DisableServerLogin := AL = 0;
  133.   end
  134. end;
  135.  
  136.  
  137. function EnableServerLogin : Boolean;
  138. { returns true if file server login is successfully enabled }
  139. { Use DisableServerLogin to disable (must be called from same WS }
  140.  
  141. var
  142.   Reply            : Word;
  143.   Request          : Record
  144.                        Len  : Word;
  145.                        SubF : Byte;
  146.                      end;
  147.  
  148. begin
  149.   Reply := 0;
  150.   with Request do begin
  151.     Len  := 1;
  152.     SubF := $CC;
  153.   end;
  154.   with NovRegs do begin
  155.     AX := $E300;
  156.     DS := Seg(Request);
  157.     SI := Ofs(Request);
  158.     ES := Seg(Reply);
  159.     DI := Ofs(Reply);
  160.     MsDos(NovRegs);
  161.     EnableServerLogin := AL = 0;
  162.   end
  163. end;
  164.  
  165. function DownFileServer(ForceItDown : Boolean) : Byte;
  166. {
  167.   DOWNS the server!!!
  168.   Warning, this function will really down your file server kiddo!
  169.   If ForceItDown is TRUE, it will down the server EVEN IF FILES ARE OPEN!!!
  170. }
  171.  
  172. var
  173.   Reply            : Word;
  174.   Request          : Record
  175.                        Len   : Word;
  176.                        SubF  : Byte;
  177.                        Force : Byte;
  178.                      end;
  179.  
  180. begin
  181.   Reply := 0;
  182.   with Request do begin
  183.     Len  := 2;
  184.     SubF := $D3;
  185.     Force := Ord(ForceItDown);
  186.   end;
  187.   with NovRegs do begin
  188.     AX := $E300;
  189.     DS := Seg(Request);
  190.     SI := Ofs(Request);
  191.     ES := Seg(Reply);
  192.     DI := Ofs(Reply);
  193.     MsDos(NovRegs);
  194.     DownFileServer := AL;
  195.   end
  196. end;
  197.  
  198. function GetLoginStatus(var LoginEnabled : Boolean) : Byte;
  199. { if Login is enabled then returns TRUE in LoginEnabled }
  200. { return byte
  201.   00h  - Success
  202.   C6h No Console Rights
  203. }
  204. var
  205.   Reply            : record
  206.                        Len     : Word;
  207.                        Flag    : Byte;
  208.                      end;
  209.   Request          : record
  210.                        Len     : Word;
  211.                        SubF    : Byte;
  212.                      end;
  213.  
  214. begin
  215.   Reply.Len := 1;
  216.   with Request do begin
  217.     Len     := 1;
  218.     SubF    := $CD;
  219.   end;
  220.   with NovRegs do begin
  221.     AX := $E300;
  222.     DS := Seg(Request);
  223.     SI := Ofs(Request);
  224.     ES := Seg(Reply);
  225.     DI := Ofs(Reply);
  226.     MsDos(NovRegs);
  227.     GetLoginStatus := AL;
  228.   end;
  229.   with Reply do
  230.     LoginEnabled := Boolean(Flag);
  231. end;
  232.  
  233. function ServerCopy(Source,Dest : Word; SOff,DOff,NoBytes : LongInt;
  234.                     var NoBytesCopied : LongInt) : Byte;
  235.  
  236. var
  237.   Request          : Record
  238.                        S,
  239.                        D   : Word;
  240.                        S_O,
  241.                        D_O,
  242.                        NB  : LongInt;
  243.                      end;
  244.  
  245. begin
  246.   with Request do begin
  247.     S  := Source;
  248.     D  := Dest;
  249.     S_O := Soff;
  250.     D_O := DOff;
  251.     NB := NoBytes;
  252.   end;
  253.   with NovRegs do begin
  254.     AX := $F300;
  255.     ES := Seg(Request);
  256.     DI := Ofs(Request);
  257.     MsDos(NovRegs);
  258.     NoBytesCopied := MakeLong(CX,DX);
  259.     ServerCopy    := AL;
  260.   end;
  261. end;
  262.  
  263. procedure PurgeAllErased;
  264. { actually delete all deleted files from server }
  265.  
  266. var
  267.   Request          : record
  268.                        Len   : Word;
  269.                        SubF  : Byte;
  270.                      end;
  271.   Reply            : Word;
  272.  
  273. begin
  274.   Reply := 0;
  275.   with Request do begin
  276.     Len := 1;
  277.     SubF := $CE;
  278.   end;
  279.   with NovRegs do begin
  280.     AX := $E300;
  281.     DS := Seg(Request);
  282.     SI := Ofs(Request);
  283.     ES := Seg(Reply);
  284.     DI := Ofs(Reply);
  285.     MsDos(NovRegs);
  286.   end;
  287. end;
  288.  
  289. procedure PurgeErased;
  290. { delete only files deleted by requesting WS from server }
  291.  
  292. var
  293.   Request          : record
  294.                        Len   : Word;
  295.                        SubF  : Byte;
  296.                      end;
  297.   Reply            : Word;
  298.  
  299. begin
  300.   Reply := 0;
  301.   with Request do begin
  302.     Len := 1;
  303.     SubF := $10;
  304.   end;
  305.   with NovRegs do begin
  306.     AX := $E200;
  307.     DS := Seg(Request);
  308.     SI := Ofs(Request);
  309.     ES := Seg(Reply);
  310.     DI := Ofs(Reply);
  311.     MsDos(NovRegs);
  312.   end;
  313. end;
  314.  
  315. function AttachToServer(ServerConnID : Byte) : Byte;
  316. { Create an attachment between a server and a workstation }
  317. { Does not Login the workstation }
  318.  
  319. begin
  320.   with NovRegs do begin
  321.     AX := $F100;
  322.     DL := ServerConnID;
  323.     MsDos(NovRegs);
  324.     AttachToServer := AL;
  325.   end;
  326. end;
  327.  
  328. function DetachFromServer(ServerConnID : Byte) : Byte;
  329. { this functions logs the object out, and detaches the workstation from }
  330. { the file server. }
  331. begin
  332.   with NovRegs do begin
  333.     AX := $F101;
  334.     DL := ServerConnID;
  335.     MsDos(NovRegs);
  336.     DetachFromServer := AL;
  337.   end;
  338. end;
  339.  
  340. end.
  341.