'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' ' Novell Netware routines for PowerBASIC 3.2 or later ' Donated to the Public Domain ' Last Revision: April 21, 1997 ' ' Contributions by: Greg Shultz 71223.431@compuserve.com ' Dave Navarro, Jr. dave@powerbasic.com ' Steve Ryckman sryckman@pobox.com ' ' This archive is maintained by Dave Navarro, Jr. If you would like to ' submit code for inclusion, please email it to me at: ' ' dave@powerbasic.com on the Internet ' or ' 74331,3520 on CompuServe ' ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' $CPU 8086 'make compatible with XT systems $LIB ALL OFF 'turn off all PowerBASIC libraries $ERROR ALL OFF 'turn off all PowerBASIC error checking $OPTIMIZE SIZE 'optimize for smaller code $COMPILE UNIT 'compile to a UNIT (.PBU) $DIM ALL 'force all variables and arrays to be declared ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovellAPI ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovellAPI(BYVAL integer, ANY, ANY) AS INTEGER ' DESC: Make a call to the Novell API. Return's true (-1) if call was ' successful. ' EXAMP: Success = NovellAPI(Service%, RequestType, ReplyType) ' FUNCTION NovellAPI(BYVAL service AS INTEGER, ANY, ANY) PUBLIC AS INTEGER ! push DS ; ! lds SI, [BP+8] ; point DS:SI to request packet ! les DI, [BP+12] ; point ES:DI to reply packet ! mov AH, Byte Ptr Service ; put service in AH ! xor AL, AL ; clear AL ! int &H21 ; call API through DOS ! xor BX, BX ; clear BX ! mov AH, BH ; clear AH ! or AL, AL ; we're we successful? ! jnz NovAPIDone ; yes, exit ! dec BX ; make it -1 NovAPIDone: ! mov AX, BX ; put return code in AX ! pop DS ; END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovCVI ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovCVI(BYVAL string) AS INTEGER ' DESC: Converts a Novell style integer into an IEEE integer. ' EXAMP: User = NovCVI( User.Object ) ' FUNCTION NovCVI(BYVAL x AS STRING) PUBLIC AS INTEGER DIM y AS LOCAL INTEGER y = CVI(x) ! mov AX, y ! xchg AL, AH ! mov y, AX FUNCTION = y END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovCVL ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovCVL(BYVAL string) AS LONG ' DESC: Converts a Novell style long into an IEEE long. ' EXAMP: User = NovCVL( User.Object ) ' FUNCTION NovCVL(BYVAL x AS STRING) PUBLIC AS LONG DIM y AS LOCAL LONG y = CVL(x) ! mov AX, y[0] ! mov BX, y[2] ! mov y[0], BX ! mov y[2], AX FUNCTION = y END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovMKI ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovMKI(BYVAL integer) AS STRING ' DESC: Converts an IEEE style integer into a Novell integer. ' EXAMP: User.Object = NovMKI(255) ' FUNCTION NovMKI(BYVAL x AS INTEGER) PUBLIC AS STRING ! mov AX, x ! xchg AL, AH ! mov x, AX FUNCTION = MKI$(x) END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovMKL ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovMKL(BYVAL long) AS STRING ' DESC: Converts an IEEE style long into a Novell long. ' EXAMP: User.Object = NovMKL(255) ' FUNCTION NovMKL(BYVAL x AS LONG) PUBLIC AS STRING ! mov AX, x[0] ! mov BX, x[2] ! mov x[0], BX ! mov x[2], AX FUNCTION = MKL$(x) END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovConnection ' AUTHOR: Greg Shultz ' DECLARE: FUNCTION NovConnection() AS INTEGER ' DESC: Return the connection number for the current workstation. If ' zero is returned, the workstation is not logged into a server. ' EXAMP: PRINT "Current connection number:"; NovConnection ' FUNCTION NovConnection () PUBLIC AS INTEGER ! mov AX, &HDC00 ; get connection id ! int &H21 ; through DOS ! xor AH, AH ; clear AH ! mov FUNCTION, AX ; return result END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovOpenBindery ' AUTHOR: Greg Shultz ' DECLARE: FUNCTION NovOpenBinery() AS INTEGER ' DESC: Returns true (-1) if the bindery was successfully opened. ' TYPE OpenBinderyRequest Length AS WORD '0001 Service AS BYTE 'subfunc 45h END TYPE TYPE OpenBinderyReply Empty AS WORD 'nothing is returned END TYPE FUNCTION NovOpenBindery () PUBLIC AS INTEGER DIM Request AS OpenBinderyRequest DIM Reply AS OpenBinderyReply Request.Length = 1 Request.Service = &H45 Reply.Empty = 0 FUNCTION = NovellAPI(&HE3, Request, Reply) END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovCloseBindery ' AUTHOR: Greg Shultz ' DECLARE: FUNCTION NovCloseBinery() AS INTEGER ' DESC: Returns true (-1) if the bindery was successfully closed. ' TYPE CloseBinderyRequest Length AS WORD '0001 Service AS BYTE 'subfunc 44h END TYPE TYPE CloseBinderyReply Empty AS WORD 'nothing is returned END TYPE FUNCTION NovCloseBindery () PUBLIC AS INTEGER DIM Request AS CloseBinderyRequest DIM Reply AS CloseBinderyReply Request.Length = 1 Request.Service = &H44 Reply.Empty = 0 FUNCTION = NovellAPI(&H3E, Request, Reply) END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovLogOutAll ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovLogOutAll() AS INTEGER ' DESC: Logs the current workstation out of all attached servers. Returns ' true (-1) if successful. ' EXAMP: CALL NovLogOutAll ' FUNCTION NovLogOutAll () PUBLIC AS INTEGER ! mov AX, &HD700 ! int &H21 ! xor AH, AH ! mov FUNCTION, AX END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovGetBCastStatus ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovGetBCastStatus() AS INTEGER ' DESC: Get the message broadcast status of the current station. ' EXAMP: Status = NovGetBCastStatus ' PRINT "Message Recieve Status: "; ' SELECT CASE Status ' CASE 0 ' PRINT "Receive all broadcasts" ' CASE 1 ' PRINT "Receive Server broadcasts only" ' CASE 2 ' PRINT "Store Server broadcasts for later" ' CASE 3 ' PRINT "Store all broadcasts for later" ' END SELECT ' FUNCTION NovGetBCastStatus() PUBLIC AS INTEGER ! push DS ; ! mov AX, &HDE00 ; Novell: Get/Set Broadcast Mode ! mov DL, 4 ; get broadcast mode ! int &H21 ; through DOS ! and AX, &HFF ; clear AH ! mov FUNCTION, AX ! pop DS ; END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovSetBCastStatus ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovSetBCastStatus(BYVAL integer) AS INTEGER ' DESC: Set the message broadcast handling for the current station. ' 0 - Receive all broadcasts ' 1 - Receive server broadcasts only ' 2 - Store server broadcasts for retrieval ' 3 - Store all broadcasts for retrieval ' EXAMP: Success = NovSetBCastStatus(NewStatus) ' FUNCTION NovSetBCastStatus(BYVAL status AS INTEGER) PUBLIC AS INTEGER ! push DS ; ! mov AX, &HDE00 ; Novell: Get/Set Broadcast Mode ! mov DX, Status ; set broadcast mode ! cmp DX, 4 ; is it an invalid mode? ! ja SetbCastExit ; yes, exit ! int &H21 ; go through DOS ! and AX, &HFF ; clear AH ! xor BX, BX ; assume failure ! cmp AX, Status ; did we get the new status? ! jnz SetbCastExit ; no, clear AX ! dec BX ; yes, return true ! mov FUNCTION, BX ; return exit code SetbCastExit: ! pop DS ; END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovServerInfo ' AUTHOR: Dave Navarro, Jr. ' DECLARE: SUB NovServerInfo(NetworkInfo AS ServerInfoType) ' DESC: Return server information for the current workstation. ' EXAMP: NovServerInfo NetworkInfo ' TYPE ServerInfoReply Length AS WORD ' Reply buffer length ClockTicks AS STRING * 4 ' Clock Ticks since system started CpuType AS BYTE ' CpuType Reserved1 AS BYTE ' Reserved Processes AS BYTE ' Number of service processes in server Workload AS BYTE ' Server utililization in percent MaxUsers AS STRING * 2 ' Maximum number of bindery objects MaxUsed AS STRING * 2 ' Maximum number of bindery objects used ServerMem AS STRING * 2 ' Server memory size in K WastedMem AS STRING * 2 ' Wasted server memory in K Reserved2 AS STRING * 38 ' Reserved info END TYPE TYPE ServerInfoRequest Length AS WORD ' Request buffer length Service AS BYTE ' Request service END TYPE TYPE ServerInfoType CpuType AS BYTE ' CpuType ClockTicks AS DWORD ' Clock Ticks since system started Processes AS BYTE ' Number of service processes in server Workload AS BYTE ' Server utililization in percent MaxUsers AS WORD ' Maximum number of bindery objects MaxUsed AS WORD ' Maximum number of bindery objects used ServerMem AS WORD ' Server memory size in K WastedMem AS WORD ' Wasted server memory in K END TYPE SUB NovServerInfo(NetworkInfo AS ServerInfoType) PUBLIC DIM Request AS ServerInfoRequest, Reply AS ServerInfoReply IF NovConnection > 0 THEN Request.Length = 2 Request.Service = &HE8 Reply.Length = LEN(Reply) - 2 IF NovellAPI(&HE3, Request, Reply) THEN NetworkInfo.CpuType = Reply.CpuType NetworkInfo.ClockTicks = NovCVL(Reply.ClockTIcks) NetworkInfo.Processes = Reply.Processes NetworkInfo.WorkLoad = Reply.WorkLoad NetworkInfo.MaxUsers = NovCVI(Reply.MaxUsers) NetworkInfo.MaxUsed = NovCVI(Reply.MaxUsed) NetworkInfo.ServerMem = NovCVI(Reply.ServerMem) NetworkInfo.WastedMem = NovCVI(Reply.WastedMem) END IF END IF END SUB ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovNetworkInfo ' AUTHOR: Dave Navarro, Jr. ' DECLARE: SUB NovNetworkInfo(string, string, string) ' DESC: Return information about the current version of Netware. ' EXAMP: NovNetworkInfo Company$, Revision$, Copyright$ TYPE NetworkInfoRequest Length AS WORD ' Request buffer length Service AS BYTE ' Request service END TYPE TYPE NetworkInfoReply Length AS WORD ' length of work space X AS STRING * 512 ' work space END TYPE SUB NovNetworkInfo(Company AS STRING, NetVer AS STRING, Copyright AS STRING) PUBLIC DIM Request AS NetworkInfoRequest, Reply AS NetworkInfoReply DIM Temp AS STRING IF NovConnection > 0 THEN Request.Length = 2 Request.Service = &HC9 Reply.Length = 512 IF NovellAPI(&HE3, Request, Reply) THEN Temp = Reply.X Company = EXTRACT$(Temp, CHR$(0)) Temp = MID$(Temp, LEN(Company)+2) NetVer = EXTRACT$(Temp, CHR$(0)) Temp = MID$(Temp, LEN(NetVer)+2) NetVer = NetVer+ " "+ EXTRACT$(Temp, CHR$(0)) Temp = MID$(Temp, LEN(NetVer)+2) Copyright = LTRIM$( EXTRACT$(Temp, CHR$(0)) ) END IF END IF END SUB ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: NovNetAddress ' AUTHOR: Dave Navarro, Jr. ' DECLARE: FUNCTION NovNetAddress$(BYVAL integer) ' DESC: Return the address of the network card installed at the specified ' connection. ' EXAMP: Address$ = NovNetAddress$( ConnectId% ) TYPE NetAddrRequest Length AS WORD ' Request buffer length Service AS BYTE ' Request service Station AS BYTE ' Logical Station END TYPE TYPE NetAddrReply Length AS WORD ' Reply buffer length Network AS DWORD ' Network Number Address AS STRING * 6 ' Physical Node Address Socket AS WORD ' Socket Number END TYPE FUNCTION NovNetAddress(BYVAL Station AS INTEGER) PUBLIC AS STRING DIM Request AS NetAddrRequest DIM Reply AS NetAddrReply DIM Temp AS STRING DIM x AS INTEGER IF Station = 0 THEN Station = NetConnection END IF Request.Length = 2 Request.Service = &H13 Request.Station = Station Reply.Length = 12 IF NovellAPI(&HE3, Request, Reply) THEN FOR X = 0 TO 2 Temp = Temp + RIGHT$( NovCVI(MID$(Reply.Address, (X*2)+1, 2)) + "00000000", 8 ) NEXT X END IF FUNCTION = Temp END FUNCTION ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' PROC: IsLocalDrive ' AUTHOR: Steve Ryckman ' DECLARE: FUNCTION IsLocalDrive(BYVAL integer) AS INTEGER ' DESC: Returns true (-1) if the specified drive is local. ' Note: CDROM drives will return false. ' EXAMP: IF IsLocalDrive( 4 ) THEN ... 'check drive D: FUNCTION IsLocalDrive(BYVAL drive AS INTEGER) PUBLIC AS INTEGER ! mov AX, &H4409 ! mov BX, drive ! int &H21 ! test DX, &H800 ! jz LocalDriveExit ! mov FUNCTION, -1 LocalDriveExit: END FUNCTION