home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / PASCAL / NWTP04 / NWSERV.PAS < prev    next >
Pascal/Delphi Source File  |  1994-01-01  |  26KB  |  825 lines

  1. {$X+,V-,B-}
  2. UNIT nwServ;
  3.  
  4. { nwServ unit as of 931228 / NwTP 0.4 API. (c) 1994, R.Spronk }
  5.  
  6. INTERFACE
  7.  
  8. uses NwMisc,nwConn;
  9.  
  10. Var result:word;
  11.  
  12. { Primary Functions:                      Interrupt: Comments:
  13.  
  14. * CheckConsolePrivileges                  (F217/C8)
  15. * ClearConnectionNumber                   (F217/D2)
  16. * DisableFileServerLogin                  (F217/CB)
  17.   DisableTransactionTracking              (F217/CF)
  18. * DownFileServer                          (F217/D3) (3)
  19. * EnableFileServerLogin                   (F217/CC)
  20.   EnableTransactionTracking               (F217/D0)
  21.   GetBinderyObjectDiskSpaceLeft           (F217/E6)
  22.   GetConnectionsOpenFiles                 (F217/DB)
  23.   GetDiskUtilization                      (F217/0E)
  24. * GetFileServerDateAndTime                (F214)
  25. * GetFileServerDescriptionStrings         (F217/C9)
  26. * GetFileserverLoginStatus                (F217/CD)
  27.   GetPathFromDirectoryEntry               (F216/1A) [E2../1A]
  28. * GetNetworkSerialNumber                  (F217/12) (2)
  29. * GetServerInformation                    (F217/11) (1)
  30. * SetFileServerDateAndTime                (F217/CA)
  31. * VerifyNetworkSerialNumber               (F217/0C) (2)
  32.  
  33.   Functions that MAY NOT be supported by NW 386:
  34.   (their F2 interfaces might work...)
  35.  
  36.   GetConnectionsTaskInformation           (F217/DA)
  37.   GetConnectionsUsageStats                (F217/E5)
  38.   GetConnectionsUsingAFile                (F217/DC)
  39.   GetDiskCacheStats                       (F217/D6)
  40.   GetDiskChannelStats                     (F217/D9)
  41.   GetDriveMappingTable                    (F217/D7)
  42.   GetFileServerLANIOStats                 (F217/E7)
  43.   GetFileSystemStats                      (F217/D4)
  44.   GetLANDriverConfigInfo                  (F217/E3)
  45.   GetLogicalRecordInformation             (F217/E0)
  46.   GetLogicalRecordsByConnection           (F217/DF)
  47.   GetPhysicalDiskStats                    (F217/D8)
  48.   GetPhysicalRecordLocksByFile            (F217/DE)
  49.   GetPhysRecLocksByConnectAndFile         (F217/DD)
  50.  
  51.  
  52.   Secondary functions:
  53.  
  54.   CheckNetwareVersion
  55.  
  56.   Not supported by netware 3.x:
  57.  
  58. - GetFileServerMiscInformation            (F217/E8) (1) (4)
  59.  
  60. Notes: The Functions marked with an - are NOT implemented in this API,
  61.        because they are not supported by NW 386.
  62.  
  63.        (1) Please don't confuse these two functions.
  64.        (2) Functions not normally supported in NW API's, but
  65.            closely related to the functions in this unit.
  66.        (3) ERROR: will down the server regardless of the ForceFlag parameter.
  67.        (4) F217/.. returns error 251: Unknown Request. Call not implemented.
  68. }
  69.  
  70.  
  71. Type TserverInfo=Record
  72.                 ServerName         : string[48];
  73.                 NetwareVersion     : Byte;
  74.                 NetwareSubVersion  : Byte; { 0..99 }
  75.                 ConnectionsMax     : word;
  76.                 ConnectionsInUse   : word;
  77.                 MaxConnVol         : word; { max connected volumes }
  78.                 {---Advanced Netware 2.1x/3.x------------}
  79.                 OS_revision        : byte;
  80.                 SFT_level          : byte;
  81.                 TTS_level          : byte;
  82.                 peak_conn_used     : word; { max simult.used connections}
  83.                 accounting_version : byte;
  84.                 vap_version        : byte;
  85.                 queuing_version               : byte;
  86.                 print_server_version          : byte;
  87.                 virtual_console_version       : byte;
  88.                 security_restrictions_level   : byte;
  89.                 Internetwork_bridge_version   : byte;
  90.                 Undefined                     : Array [1..60] of Byte;
  91.                 End;
  92.  
  93. Type TfileInfoRecord=record
  94.                      taskNbr:Byte;
  95.                      lockFlag:Byte;
  96.                      AccessFlag:Byte;
  97.                      LockType:Byte; { 00 no lock; FE file lock; FF locked by Begin Share File Set }
  98.                      volumeNbr:Byte; { 0..31 }
  99.                      DirEntry:Word;
  100.                      FileName:string[13];
  101.                      end;
  102.  
  103. {Bitfields for lock flags:
  104.  bit 0    file is locked
  105.  bit 1    file opened Shareable
  106.  bit 2    logged
  107.  bit 3    file opened Normal
  108.  bit 6    TTS holding lock
  109.  bit 7    Transaction Flag set on file
  110.  
  111. Bitfields for access flags:
  112.  bit 0    file open for reading by calling station
  113.  bit 1    file open for writing by calling station
  114.  bit 2    deny reads by other stations
  115.  bit 3    deny writes by other stations
  116.  bit 4    file detached
  117.  bit 5    TTS Holding Detach
  118.  bit 6    TTS Holding Open}
  119.  
  120.  
  121.  
  122. {F217/C8 [2.15c+]}
  123. FUNCTION CheckConsolePrivileges : Boolean;
  124.  
  125. {F217/D2 [2.15c+]}
  126. Function ClearConnectionNumber(connectionNbr:byte):boolean;
  127. { Console Rights needed;
  128.   -Terminates a connection. }
  129.  
  130. {F217/CB [2.15c+]}
  131. FUNCTION DisableFileServerLogin : Boolean;
  132.  
  133. {F217/CF [2.15c+]}
  134. FUNCTION DisableTransactionTracking : Boolean;
  135.  
  136. {F217/D3 [2.15c+]}
  137. FUNCTION DownFileServer (ForceFlag : Boolean) : Boolean;
  138.  
  139. {F217/CC [2.15c+]}
  140. FUNCTION EnableFileServerLogin : Boolean;
  141.  
  142. {F217/D0 [2.15c+]}
  143. FUNCTION EnableTransactionTracking : Boolean;
  144.  
  145. {F217/E6 [2.15c+]}
  146. FUNCTION GetBinderyObjectDiskSpaceLeft
  147.             (    ObjID : longInt;
  148.              var SystemElapsedTime,UnusedDiskBlocks : longint;
  149.              var RestrictionEnforced : Boolean             ) : Boolean;
  150.  
  151. {F217/DB [2.15c+]}
  152. FUNCTION GetConnectionsOpenFiles
  153.            ( ConnID,ConnNumber  : Byte;
  154.      {i/o:}  var LastRecordSeen : word;
  155.      {out:}  var FileInfo: TfileInfoRecord ) : Boolean;
  156. { To be called Iteratively.
  157.   LastRecordSeen is an i/o parameter;
  158.   -An initial value of 0 has to be supplied;
  159.   -The function can be called until LastRecordSeen becomes 0,
  160.    indicating the end of the FIR-list. }
  161. { normally a great number of File Information Records (FIR's) can be returned by one call.
  162.   We have changed the function so that it returns one FIR per call. }
  163. { the calling workstation must have console operator privileges. }
  164.  
  165.  
  166. {F217/0E [2.15c+]}
  167. FUNCTION GetDiskUtilization(volNbr:byte; objID:Longint;
  168.                         Var usedDirs,usedFiles,usedBlocks:Word ):Boolean;
  169.  
  170. {F214    [2.15c+]}
  171. FUNCTION GetFileServerDateAndTime ( Var time:NovTimeRec): Boolean;
  172.  
  173. {F217/C9 [2.15c+]}
  174. FUNCTION GetFileServerDescriptionStrings(Var companyName,
  175.                                              VersionAndRevision,revisionDate,
  176.                                              copyrightNotice:String
  177.                                          ):Boolean;
  178.  
  179. {F217/CD [2.15c+]}
  180. FUNCTION GetFileServerLoginStatus (Var LoginEnabled:Boolean): Boolean;
  181. { if Login is enabled then returns TRUE in LoginEnabled }
  182. { rusult byte:  00h  - Success, C6h No Console Rights }
  183. {Caller must have operator status.}
  184.  
  185.  
  186. {F216/1A [2.15c+]}
  187. FUNCTION GetPathFromDirectoryEntry(connID:word;
  188.                                    volNbr:Byte; dirEntry:word;
  189.                                Var Path:String                ):Boolean;
  190. {To be used in conjunction with the GetConnectionsOpenFiles func.}
  191.  
  192. {F217/12 [2.15c+]}
  193. Function GetNetworkSerialNumber(Var serialNbr:LongInt; Var ApplicNbr:Word ):Boolean;
  194. {return the serial number and application number for the software
  195.       installed on the file server}
  196. {SeeAlso: VerifyNetworkSerialNumber,GetServerInformation}
  197.  
  198. {F217/11 [2.15c+]}
  199. Function GetServerInformation (Var serverInfo:TserverInfo):boolean;
  200. {determine the version of software installed on the file server and how it is configured}
  201.  
  202.  
  203. {F217/CA [2.15c+]}
  204. FUNCTION SetFileServerDateAndTime(time:NovTimeRec):Boolean;
  205. {need console operator privileges to do this}
  206.  
  207. {F217/OC [2.15c+]}
  208. Function VerifyNetworkSerialNumber(serialNbr: LongInt ;
  209.                                Var ApplicNbr: Word     ):Boolean;
  210. {if the network serial number to be verified is correct, the reply
  211.       buffer will contain the corresponding application number }
  212.  
  213. {*********************** Secondary Functions ******************************}
  214.  
  215. { [1.x/2.x/3.x] }
  216. FUNCTION CheckNetwareVersion(MinimumVersion,MinimumSubVersion,
  217.                              MinimumRevision,MinimumSFT,MinimumTTS:word):Boolean;
  218.  
  219. IMPLEMENTATION{=============================================================}
  220.  
  221.  
  222. USES Dos;
  223.  
  224. Var UnitReqBuffer:array[1..576] of byte;
  225.     UnitReplyBuffer:array[1..576] of byte;
  226.     UnitRegs:registers;
  227.  
  228. Procedure F2SystemCall(subf:byte;req_size,rep_size:word);
  229. begin
  230. With UnitRegs
  231.  do begin
  232.     DS := Seg(UnitReqBuffer);  SI := Ofs(UnitReqBuffer);   CX := Req_size;
  233.     ES := Seg(UnitReplyBuffer);DI := Ofs(UnitReplyBuffer); DX := rep_size;
  234.     AH := $F2; AL := subf;
  235.     MSDOS(UnitRegs);
  236.     Result:=al;
  237.     end;
  238. end;
  239.  
  240.  
  241. {F217/D2 [2.15c+]}
  242. Function ClearConnectionNumber(connectionNbr:byte):boolean;
  243. { Console Rights needed;
  244.   -Terminates a connection. }
  245. Var req: record
  246.          len : word;
  247.          subf: byte;
  248.          _connNbr:byte;
  249.          end          ABSOLUTE UnitReqBuffer;
  250. begin
  251. With req
  252. do begin
  253.    len:=2;
  254.    subf:=$D2;
  255.    _connNbr:=connectionNbr
  256.    end;
  257. F2SystemCall($17,SizeOf(req),0);
  258. ClearConnectionNumber:=(result=0);
  259. {result codes: 00 successful; C6 No Console Rights}
  260. end;
  261.  
  262. {F214 [2.15c+]}
  263. FUNCTION GetFileServerDateAndTime ( Var time:NovTimeRec): Boolean;
  264. Var reply : NovTimeRec ABSOLUTE UnitReplyBuffer;
  265. BEGIN
  266. F2SystemCall($14,0,SizeOf(reply));
  267. time:=reply;
  268. if time.year>100 then time.year:=time.year-100;
  269. { year<80 : 21st century }
  270. getFileServerDateAndTime:=TRUE;
  271. end;
  272.  
  273.  
  274. {F217/CA [2.15c+]}
  275. FUNCTION SetFileServerDateAndTime (time:NovTimeRec): Boolean;
  276. Var req  : record
  277.            Len:word;
  278.            subF:byte;
  279.            _time:NovTimeRec
  280.            end              ABSOLUTE UnitReqBuffer;
  281. BEGIN
  282. { year<80 : 21st century }
  283. WITH req
  284. do begin
  285.    Len:=SizeOf(req)-3; { dow is no parameter }
  286.    subF:=$CA;
  287.    _time:=time;
  288.    end;
  289. F2SystemCall($17,SizeOf(req),0);
  290. SetFileServerDateAndTime:=(Result=$00);
  291. { Resulcodes: $00 Success; $C6 No Console Operator Rights }
  292. end;
  293.  
  294.  
  295. {F217/11 [2.15c+]}
  296. Function GetServerInformation (Var serverInfo:TserverInfo):boolean;
  297. {determine the version of software installed on the file server and how it is configured}
  298.  
  299. {SeeAlso: GetDiskUtilization, GetNetworkSerialNumber, GetFileServerLoginStatus,
  300.           GetFileServerDateAndTime}
  301.  
  302. Var  Request: Record
  303.               Len  : word;
  304.               SubF : Byte;
  305.               End         ABSOLUTE UnitReqBuffer;
  306.      Reply: TserverInfo   ABSOLUTE UnitReplyBuffer;
  307.      t:word;
  308. Begin
  309. With Request
  310. Do Begin
  311.    Len := 1;
  312.    SubF:= $11;
  313.    End;
  314. F2SystemCall($17,SizeOf(request),SizeOf(reply)-1);
  315. Move(UnitReplyBuffer[1],UnitReplyBuffer[2],SizeOf(reply)-1);
  316. serverInfo:=reply;
  317. With serverinfo
  318. do begin
  319.    connectionsMax  :=Swap(connectionsMax);   { force lo-hi again }
  320.    ConnectionsInUse:=Swap(connectionsInUse);
  321.    MaxConnVol      :=Swap(maxConnVol);
  322.    peak_conn_used  :=Swap(peak_conn_used);
  323.    for t:=48 downto 1
  324.     do if serverInfo.serverName[t]=#0 then serverInfo.serverName[0]:=chr(t-1);
  325.    end;
  326. GetServerInformation:=(result=0);
  327. End;
  328.  
  329.  
  330.  
  331. {F217/C9 [2.15c+]}
  332. FUNCTION GetFileServerDescriptionStrings(Var companyName,
  333.                                              VersionAndRevision,revisionDate,
  334.                                              copyrightNotice:String
  335.                                          ):Boolean;
  336. {SeeAlso: GetFileServerLoginStatus, GetServerInformation. }
  337. Var  x,xofs : word;
  338.      request : record
  339.                len : word;
  340.                subf: byte;
  341.                end         ABSOLUTE UnitReqBuffer;
  342.      reply : record
  343.              stuff : array [1..512] of byte;
  344.              end           ABSOLUTE UnitReplyBuffer;
  345. begin
  346. With request
  347. do begin
  348.    len  := 1;
  349.    subf := $c9;
  350.    end;
  351. F2SystemCall($17,SizeOf(request),SizeOf(reply));
  352. companyName:=''; VersionAndRevision:='';
  353. revisionDate:=''; copyrightNotice:='';
  354. if result=$00
  355. then begin
  356.  
  357.      x:=1;xofs:=x;
  358.      while (reply.stuff[x]<>$00) and (x<512) do inc(x);
  359.      ZStrCopy(companyName,reply.stuff[xofs],x-xofs);
  360.  
  361.      inc(x);xofs:=x; { skip 1 zero. ? skip more zero's? }
  362.      While (reply.stuff[x]<>$00) and (x<512) do inc(x);
  363.      ZStrCopy(VersionAndRevision,reply.stuff[xofs],x-xofs);
  364.  
  365.      inc(x);xofs:=x;
  366.      While (reply.stuff[x]<>$00) and (x<512) do inc(x);
  367.      ZStrCopy(revisionDate,reply.stuff[xofs],x-xofs); { mm/dd/yy }
  368.  
  369.      inc(x);xofs:=x;
  370.      While (reply.stuff[x]<>$00) and (x<512) do inc(x);
  371.      ZStrCopy(copyrightNotice,reply.stuff[xofs],x-xofs);
  372.      end;
  373.  
  374. GetFileServerDescriptionStrings:=(Result=$00);
  375. end;
  376.  
  377.  
  378.  
  379. {F217/D3 [2.15c+]}
  380. FUNCTION DownFileServer (ForceFlag : Boolean) : Boolean;
  381. Var request : record
  382.               len : word;
  383.               subf: byte;
  384.               down_flag : byte;
  385.               end           ABSOLUTE UnitReqBuffer;
  386. BEGIN
  387. With request
  388. do begin
  389.    len  := 2;
  390.    subf := $D3;
  391.    if ForceFlag then down_flag := $01
  392.                 else down_flag := $00;
  393.    end;
  394. F2SystemCall($17,SizeOf(request),0);
  395. DownFileServer:=(result=0);
  396. { resultcodes: 00=successful; C6 No Console Rights ; FF Open Files}
  397. end;
  398.  
  399.  
  400. {F217/CF [3.x]}
  401. FUNCTION DisableTransactionTracking : Boolean;
  402. { Caller must have console-operator rights. }
  403. Var request : record
  404.               len : word;
  405.               subf: byte
  406.               end         ABSOLUTE UnitReqBuffer;
  407. BEGIN
  408. With request
  409. do begin
  410.    len := 1;
  411.    subf:= $CF;
  412.    end;
  413. F2SystemCall($17,SizeOf(request),0);
  414. DisableTransactionTracking:=(result=0);
  415. { resultcodes: 00=successful; C6 No Console Rights }
  416. end;
  417.  
  418.  
  419. {F217/D0 [3.x]}
  420. FUNCTION EnableTransactionTracking : Boolean;
  421. { Caller must have console-operator rights. }
  422. Var request : record
  423.               len : word;
  424.               subf: byte
  425.               end         ABSOLUTE UnitReqBuffer;
  426. BEGIN
  427. With request
  428. do begin
  429.    len := 1;
  430.    subf:= $D0;
  431.    end;
  432. F2SystemCall($17,SizeOf(request),0);
  433. EnableTransactionTracking:=(result=0);
  434. { resultcodes: 00=successful; C6 No Console Rights }
  435. end;
  436.  
  437.  
  438. {F217/CB [2.15c+]}
  439. FUNCTION DisableFileServerLogin : Boolean;
  440. { Caller must have console-operator rights. }
  441. Var request : record
  442.               len : word;
  443.               subf: byte
  444.               end        ABSOLUTE UnitReqBuffer;
  445. BEGIN
  446. With request
  447. do begin
  448.    len := 1;
  449.    subf:= $CB;
  450.    end;
  451. F2SystemCall($17,SizeOf(request),0);
  452. DisableFileServerLogin:=(result=0);
  453. { resultcodes: 00=successful; C6 No Console Rights }
  454. end;
  455.  
  456.  
  457.  
  458. {F217/CC [2.15c+]}
  459. FUNCTION EnableFileServerLogin : Boolean;
  460. { Caller needs console-operator rights. }
  461. Var request : record
  462.               len : word;
  463.               subf: byte
  464.               end         ABSOLUTE UnitReqBuffer;
  465. BEGIN
  466. With request
  467. do begin
  468.    len := 1;
  469.    subf:= $CC;
  470.    end;
  471. F2SystemCall($17,SizeOf(request),0);
  472. EnableFileServerLogin:=(result=0);
  473. { resultcodes: 00=successful; C6 No Console Rights }
  474. end;
  475.  
  476.  
  477.  
  478. {F217/CD [2.15c+]}
  479. FUNCTION GetFileServerLoginStatus( Var LoginEnabled:Boolean ): Boolean;
  480. { if Login is enabled then returns TRUE in LoginEnabled }
  481. { result byte:  00h  - Success, C6h No Console Rights }
  482. { Caller must have operator status.}
  483. Var Reply  : record
  484.              Flag    : Byte;
  485.              end            ABSOLUTE UnitReplyBuffer;
  486.    Request : record
  487.              Len     : Word;
  488.              SubF    : Byte;
  489.              end            ABSOLUTE UnitReqBuffer;
  490. begin
  491. with Request
  492. do begin
  493.    Len     := 1;
  494.    SubF    := $CD;
  495.    end;
  496. F2SystemCall($17,SizeOf(request),SizeOf(reply));
  497. LoginEnabled:=Boolean(Reply.Flag);
  498. GetFileServerLoginStatus := (result=0);
  499. end;
  500.  
  501.  
  502. {F217/C8 [2.15c+]}
  503. FUNCTION CheckConsolePrivileges : Boolean;
  504. Var Request : record
  505.               Len  : Word;
  506.               SubF : Byte;
  507.               end         ABSOLUTE UnitReqBuffer;
  508. begin
  509. with Request
  510. do begin
  511.    Len  := 1;
  512.    SubF := $C8;
  513.    end;
  514. F2SystemCall($17,SizeOf(request),0);
  515. CheckConsolePrivileges := (Result=$00);
  516. { result byte:  00h  - Success, C6h No Console Rights }
  517. end;
  518.  
  519.  
  520. {F217/E6 [3.x]}
  521. FUNCTION GetBinderyObjectDiskSpaceLeft
  522.             ( ObjID : longInt;
  523.              var SystemElapsedTime,UnusedDiskBlocks : longint;
  524.              var RestrictionEnforced : Boolean             ) : Boolean;
  525. { Caller needs console-operator rights. }
  526. Var Request : record
  527.               Len   : Word;
  528.               SubF  : Byte;
  529.               _objID: Longint; {hi-lo}
  530.               end               ABSOLUTE UnitReqBuffer;
  531.     Reply   : record
  532.               _SysElapTime: Longint; {hi-lo} { ticks since system-up }
  533.               _objId      : Longint; {hi-lo}
  534.               _UnUsedDBl  : Longint; {hi-lo}
  535.               _RestrEnforced:Byte;
  536.               end               ABSOLUTE UnitReplyBuffer;
  537. begin
  538. with Request
  539. do begin
  540.    Len  := SizeOf(Request)-2;
  541.    SubF := $E6;
  542.    _objId:=Lswap(objID); {force hi-lo}
  543.    end;
  544. F2SystemCall($17,SizeOf(request),SizeOf(reply));
  545. if result=$00
  546. then with reply
  547.      do begin
  548.         systemElapsedTime:=Lswap(_sysElapTime); {force lo-hi}
  549.         UnusedDiskBlocks :=Lswap(_UnUsedDBl);   {force lo-hi}
  550.         RestrictionEnforced:=(_RestrEnforced=$00); {00 enforced, FF not enforced }
  551.         end;
  552. if request._objId<>reply._objId then result:=$101;
  553.  
  554. GetBinderyObjectDiskSpaceLeft:=(Result=0);
  555. { Resultcodes: 00: successful; C6 No Console Rights }
  556. end;
  557.  
  558.  
  559. {F217/DB [2.15c+]}
  560. FUNCTION GetConnectionsOpenFiles
  561.            ( ConnID,ConnNumber  : Byte;
  562.      {i/o:}  var LastRecordSeen : word;
  563.      {out:}  var FileInfo: TfileInfoRecord ) : Boolean;
  564.  
  565. { the calling workstation must have console operator privileges }
  566. { LastRecordSeen is an i/o parameter;
  567.   -An initial value of 0 has to be supplied;
  568.   -The function can be called until LastRecordSeen becomes 0,
  569.    indicating the end of the FIR-list.
  570.  
  571.   to be called iteratively. }
  572.  
  573. Type Barr=array[1..14] of byte;
  574. Var Req: record
  575.          len:word;
  576.          subf:byte;
  577.          logicalConnNbr:word; {hi-lo}
  578.          lastRecSeen:word; {hi-lo, $0000 on first call }
  579.          end                 ABSOLUTE UnitReqBuffer;
  580.     Reply: record
  581.            nextReqRec : word; { hi-lo, use as lastRecSeen in next iterative call }
  582.                               { $0000 if no more records }
  583.            RecCount   : byte;
  584.            FileInfoRec: TfileInfoRecord;
  585.            fill:array[1..10] of byte;
  586.            end               ABSOLUTE UnitReplyBuffer;
  587.     resConnID:Byte;
  588.  
  589. { normally a great number of File Information Records can be returned by one call.
  590.   We have changed the function so that it returns one FIR per call. }
  591.  
  592. begin
  593. { !! set server with connID as preferred server !  }
  594. GetPreferredConnectionID(resConnID);
  595. SetPreferredConnectionID(connID);
  596.  
  597. With req
  598. do begin
  599.    len:=sizeof(req)-2;
  600.    subf:=$DB;
  601.    logicalConnNbr:=swap(connNumber); { force hi-lo }
  602.    lastRecSeen:=swap(LastRecordSeen); { force hi-lo }
  603.    end;
  604. F2SystemCall($17,SizeOf(req),SizeOf(reply));
  605. if result=$00
  606. then begin
  607.      if reply.recCount<>1
  608.      then result:=$101
  609.      else begin
  610.           LastRecordSeen:=swap(reply.NextReqRec); { force lo-hi }
  611.           FileInfo:=Reply.FileInfoRec;
  612.           fileinfo.DirEntry:=swap(fileinfo.DirEntry); { force lo-hi again }
  613.           ZstrCopy(fileInfo.filename,Barr(reply.FileInfoRec.filename),14);
  614.           end;
  615.      end;
  616.  
  617. { !! reset old preferred server ! }
  618. SetPreferredConnectionID(resConnID);
  619.  
  620. GetConnectionsOpenFiles:=(result=$00);
  621. { errorcodes: $00 Success; $C6 no console privileges }
  622. end;
  623.  
  624.  
  625. {F216/1A [2.x/3.x]}
  626. FUNCTION GetPathFromDirectoryEntry( connID:word;
  627.                                     volNbr:Byte; dirEntry:word;
  628.                                 Var Path:String                ):Boolean;
  629. {To be used in conjunction with the GetConnectionsOpenFiles func.
  630.  SeeAlso: GetConnectionsOpenFiles,
  631.           GetDirectoryPath (nwDir),GetVolumeName (nwDir).}
  632. Var Req: record
  633.          len:word;
  634.          subf:byte;
  635.          _volNbr:byte;
  636.          _dirEntry:word; {hi-lo}
  637.          end                ABSOLUTE UnitReqBuffer;
  638.     Reply: record
  639.            _Path:array[1..256] of byte;
  640.            end              ABSOLUTE UnitReplyBuffer;
  641.     resConnID:Byte;
  642. begin
  643. { !! set server with connID as preferred server !  }
  644. GetPreferredConnectionID(resConnID);
  645. SetPreferredConnectionID(connID);
  646.  
  647. With req
  648. do begin
  649.    len:=sizeof(req)-2;
  650.    subf:=$1A;
  651.    _volNbr:=volNbr;
  652.    _dirEntry:=swap(dirEntry); { force hi-lo }
  653.    end;
  654. F2SystemCall($16,SizeOf(req),SizeOf(reply));
  655. if result=$00
  656. then ZstrCopy(Path,reply._path,255)
  657. else path:='';
  658.  
  659. { !! reset old preferred server ! }
  660. SetPreferredConnectionID(resConnID);
  661.  
  662. GetPathFromDirectoryEntry:=(result=$00);
  663. { errorcodes: $00 Success; $C6 no console privileges }
  664. end;
  665.  
  666.  
  667. {F217/0E 2.15c+}
  668. FUNCTION GetDiskUtilization(volNbr:byte; objID:Longint;
  669.                         Var usedDirs,usedFiles,usedBlocks:Word ):Boolean;
  670. { SeeAlso: GetServerInformation,getBinderyObjectDiskSpaceLeft }
  671. Var Reply   : record
  672.               _volNbr:Byte;
  673.               _objID:Longint; {hi-lo}
  674.               _usedDirs,_usedFiles,_usedBlocks:Word; { all hi-lo }
  675.               end           ABSOLUTE UnitReplyBuffer;
  676.     Request : record
  677.               Len  : Word;
  678.               SubF : Byte;
  679.               _volNbr:Byte;
  680.               _objID:longInt; { hi-lo }
  681.               end           ABSOLUTE UnitReqBuffer;
  682. begin
  683. with Request
  684. do begin
  685.    Len  := SizeOf(Request)-2;
  686.    SubF := $0E;
  687.    _volNbr:=volNbr;
  688.    _objID:=Lswap(objID);
  689.    end;
  690. F2SystemCall($17,SizeOf(request),SizeOf(reply));
  691. if result=$00
  692. then begin
  693.      with Reply
  694.      do begin
  695.         usedDirs:=swap(_usedDirs);    { force lo-hi }
  696.         usedFiles:=swap(_usedFiles);  { force lo-hi }
  697.         usedBlocks:=swap(_usedBlocks);{ force lo-hi }
  698.         end;
  699.      end;
  700. GetDiskUtilization:=(result=$00);
  701. {Resultcodes: 00h successful; 98h volume dosn't exist
  702.              F2h no Object read privileges }
  703. end;
  704.  
  705.  
  706. {F217/12 [2.15c+]}
  707. Function GetNetworkSerialNumber(Var serialNbr:LongInt; Var ApplicNbr:Word ):Boolean;
  708. {return the serial number and application number for the software
  709.       installed on the file server}
  710. {SeeAlso: VerifyNetworkSerialNumber,GetServerInformation}
  711. Var Reply  : record
  712.              _serNbr   : LongInt; {hi-lo}
  713.              _applicNbr: Word;    {hi-lo}
  714.              end                  ABSOLUTE UnitReplyBuffer;
  715.    Request : record
  716.              Len     : Word;
  717.              SubF    : Byte;
  718.              end                  ABSOLUTE UnitReqBuffer;
  719. begin
  720. with Request
  721. do begin
  722.    Len     := 1;
  723.    SubF    := $12;
  724.    end;
  725. F2SystemCall($17,SizeOf(request),SizeOf(reply));
  726. with reply
  727. do begin
  728.    ApplicNbr:=swap(_applicNbr);   { force lo-hi }
  729.    serialNbr:=Lswap(_serNbr);     { force lo-hi }
  730.    end;
  731. GetNetworkSerialNumber := (result=0);
  732. end;
  733.  
  734.  
  735.  
  736. {F217/OC [2.15c+]}
  737. Function VerifyNetworkSerialNumber(serialNbr: LongInt ;
  738.                                Var ApplicNbr: Word     ):Boolean;
  739. {if the network serial number to be verified is correct, the reply
  740.       buffer will contain the corresponding application number }
  741. {SeeAlso: GetNetworkSerialNumber}
  742. Var Reply  : record
  743.              _applicNbr: word; {hi-lo}
  744.              end                ABSOLUTE UnitReplyBuffer;
  745.    Request : record
  746.              Len        : Word;
  747.              SubF       : Byte;
  748.              _netwSerNbr: LongInt; {hi-lo}
  749.              end                ABSOLUTE UnitReqBuffer;
  750. begin
  751. with Request
  752. do begin
  753.    Len     := 1;
  754.    SubF    := $0C;
  755.    _netwSerNbr:=Lswap(serialNbr);
  756.    end;
  757. F2SystemCall($17,SizeOf(request),SizeOf(reply));
  758. with reply
  759. do begin
  760.    ApplicNbr:=swap(_applicNbr); { force lo-hi }
  761.    end;
  762. VerifyNetworkSerialNumber := (result=0);
  763. end;
  764.  
  765.  
  766. {****************** secondary functions ************************************}
  767.  
  768.  
  769. {OLD E3 Call, used by CheckNetwareVersion}
  770. Function GetE3ServerInformation (Var serverInfo:TserverInfo):boolean;
  771. Var  Reg            : Registers;
  772.      RequestBuffer  : Record
  773.                       PacketLength : Integer;
  774.                       FunctionVal  : Byte;
  775.                       End;
  776.      Replylength:word ABSOLUTE serverInfo;
  777.      t:byte;
  778. Begin
  779. With RequestBuffer
  780. Do Begin
  781.    PacketLength := 1;
  782.    FunctionVal := $11;
  783.    End;
  784. ReplyLength := $80;
  785. With Reg
  786. Do Begin
  787.    Ah := $e3;
  788.    Ds := Seg(RequestBuffer);
  789.    Si := Ofs(RequestBuffer);
  790.    Es := Seg(ServerInfo);
  791.    Di := Ofs(ServerInfo);
  792.    End;
  793. MsDos(Reg);
  794. result:=reg.AL;
  795. GetE3ServerInformation:=(result=0);
  796. End;
  797.  
  798.  
  799. FUNCTION CheckNetwareVersion(MinimumVersion,MinimumSubVersion,
  800.                              MinimumRevision,MinimumSFT,MinimumTTS:word):Boolean;
  801. { checks if the current OS/TTS/SFT version is greater or equal to the minimal version }
  802. Var info:TserverInfo;
  803.     res:boolean;
  804. begin
  805. IF GetServerInformation(info) OR GetE3ServerInformation(info)
  806. then begin
  807.      IF (info.NetwareVersion>MinimumVersion)
  808.        then res:=true
  809.        else if (info.NetwareVersion=MinimumVersion)
  810.                AND (info.NetwareSubVersion>MinimumSubVersion)
  811.             then res:=true
  812.             else if (info.NetwareVersion=MinimumVersion)
  813.                     AND (info.NetwareSubVersion=MinimumSubVersion)
  814.                     AND (info.OS_Revision>=MinimumRevision)
  815.                  then res:=true
  816.                  else res:=false
  817.      end
  818. else res:=false;
  819.  
  820. CheckNetwareVersion:=res AND (info.SFT_Level>=MinimumSFT)
  821.                          AND (info.TTS_Level>=MinimumTTS)
  822. end;
  823.  
  824.  
  825. end. {unit nwServ}