Ðåôåðàò: Èíòðàíåò ñåòè
r.si := ofs(SendPacket);
r.es := seg(ReplyPacket);
r.di := ofs(ReplyPacket);
intr($21,r);
end;
end.
Ñëåäóþùàÿ ïðîãðàììà äåìîíñòðèðóåò âîçìîæíîñòü ïîëó÷åíèÿ ñïèñêà ïîëü-
çîâàòåëåé, ïîäêëþ÷åííûõ ê ñåòè:
uses Dos;
function GetWord(P: pointer): word;
var
WordPtr :^word;
begin
WordPtr := P;
GetWord := swap(WordPtr^);
end;
Function GetLong(P:Pointer): longint;
type long= record
case integer of
1:(Long1: Longint);
2:(Word1,Word2:word);
end;
var LongPtr :^Long;
L : long;
begin
LongPtr := P;
L.Word1 := swap(LongPtr^.Word2);
L.Word2 := swap(LongPtr^.Word1);
GetLong:= L.Long1;
end;
Function GetConnectionInformation(ConnectionNumber:byte;
Var ObjectName : string; var ObjectType : word;
var ObjectID : longint; var LoginTime : string): byte;
var
WordPtr:^Word;
r:registers;
SendPacket : array[0..4] of byte;
ReplyPacket : array[0..64] of byte;
begin
SendPacket[2] := $16;
SendPacket[3] := ConnectionNumber;
WordPtr := addr(SendPacket);
WordPtr^:=2;
WordPtr := addr(SendPacket);
WordPtr^ := 62;
r.ah := $e3;
r.ds := seg(SendPacket);
r.si := ofs(SendPacket);
r.es := seg(ReplyPacket);
r.di := ofs(ReplyPacket);
intr($21,r);
if r.al = 0
then
begin
ObjectID := GetLong(addr(ReplyPacket[2]));
ObjectType := GetWord(addr(ReplyPacket[6]));
move(ReplyPacket[8],ObjectName[1],48);
ObjectName[0] := chr(48);
move(ReplyPacket[56],LoginTime[1],7);
LoginTime[0] := chr(7);
end;
GetConnectionInformation := r.al;
end;
var
ObjectName,LoginTime : string;
ObjectType : word;
ObjectID : longint;
ConnectionNumber, CCode : byte;
begin
ConnectionNumber := 1;
CCode := GetConnectionInformation(ConnectionNumber,
ObjectName,ObjectType,ObjectID,LoginTime);
while (CCode <> 253) and (ConnectionNumber<255)
do
begin
if CCode <> 0
then
writeln('Cod ',CCode,ConnectionNumber)
else if ObjectType <>0 then begin
Writeln(ConnectionNumber,' ',ObjectType,' ',ObjectID);
Writeln(ObjectName);
end;
inc(ConnectionNumber);
CCode := GetConnectionInformation(ConnectionNumber,
ObjectName,ObjectType,ObjectID,LoginTime);
end;
end.
5. ÐÀÁÎÒÀ Ñ ÔÀÉËÀÌÈ Â ËÂÑ.
Íèæå ïðèâîäÿòñÿ òåêñòû ïðîöåäóð, èñïîëüçóåìûõ ïðè ðàáîòå â ËÂÑ
äëÿ îáñëóæèâàíèÿ ôàéëîâîé ñèñòåìû:
; Äàííàÿ áèáëèîòåêà ïðîöåäóð ðàçðàáîòàíà äëÿ èñïîëüçîâàíèÿ â ïðîã-
; ðàììàõ, íàïèñàííûõ íà Òóðáî-Ïàñêàëå âåðñèè 4.0 è âûøå.
; Joe R. Doupnik and Sergey V. Perevoznik, 1988 - 1993
lprog equ 1 ; 0 for small memory, 1 for large memory model
; Modify lprog to match the memory model
if lprog
x equ 6 ; prologue overhead for large memory model
else
x equ 4 ; ditto, small memory model
endif
begin macro name ; begin a function, near or far
public name
if lprog
name proc far
else
name proc near
endif
endm
; define Borland Pascal segments
; use neither Group nor Class
data segment word public
data ends
cseg segment byte public
assume cs:cseg, ds:data, es:nothing
;--------------------------------
; Extended Open a File func(61) (3DH)
;
; var
; Mode, Handle, RetCode : Integer;
; Filename : String[n];
;
; RetCode := xtndopn(Mode, Handle, Filename);
;
begin xtndopn
push bp
mov bp,sp
push ds
lds si,[bp+x+8] ; put the mode in ax
mov ax,[si]
mov ah,03Dh ; put the function in ah
lds dx,[bp+x] ; ptr to ASCIIZ string
inc dx ; add 1 to get to the beginning of the string
int 21h
jc xtndopx ; carry set means failure
lds di,[bp+x+4] ; put the handle into the variable
mov [di],ax ; if there is no error and
xor ax,ax ; return a 0
xtndopx:pop ds
pop bp
ret 14
xtndopn endp
;--------------------------------
; Get or Set File Attributes(handle) func(67) (43H)
;
; var
; Func, Attribute, ErrCode : Integer;
; Filename : String[n];
;
;ErrCode := setattr(Func, Attribute, Filename);
;
begin setattr
push bp
mov bp,sp
push ds
lds si,[bp+x+8] ; put the subfunction in ax
mov ax,[si]
mov ah,043h ; put the function in ah
lds dx,[bp+x] ; ptr to var desc block for ASCIIZ string
inc dx ; add 1 to get the address of the string
lds si,[bp+x+4] ; put the attribute to set in cx
mov cx,[si]
int 21h
jc setattx ; carry set means failure
lds di,[bp+x+4] ; put the returned attributes in the
mov [di],cx ; variable if there is no error
xor ax,ax ; and return zero
setattx:mov ah,0
pop ds
pop bp
ret 14
setattr endp
;--------------------------------
; End of Job Flag Status func(187) (BBH)
;
; var
; Flag : Integer;
;
;ErrCode := eojstat(Flag);
;
begin eojstat
push bp
mov bp,sp
push ds
lds si,[bp+x] ; put the flag in ax
mov ax,[si]
mov ah,0BBh ; put the function in ah
int 21h
mov ah,0
lds di,[bp+x]
mov [di],ax
pop ds
pop bp
ret 6
eojstat endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Physical Record Lock: Log Record BCH
;
; var
; ErrCode,FileHandle,HiByteOffset,LoByteOffset : Integer
; HiLockLen,LoLockLen,Flags,TimeOut : Integer
;
;ErrCode := PRLH_Log(FileHandle,HiByteOffset,LoByteOffset,HiLockLen,
; LoLockLen,Flags,TimeOut);
;
begin PRLH_Log
push bp
mov bp,sp
push ds
lds si,[bp+x+24] ; FileHandle
mov bx,[si]
lds si,[bp+x+20] ; ByteOffset
mov cx,[si]
lds si,[bp+x+16]
mov dx,[si]
lds si,[bp+x+4] ; AL = Log Flags
mov ax,[si]
lds si,[bp+x+12] ; LockLen
mov si,[si]
lds di,[bp+x+8]
mov di,[di]
lds bp,[bp+x] ; time out
mov bp,[bp]
mov ah,0BCH
int 21H
mov ah,0 ; clear the high byte of the return
pop ds
pop bp
ret 30
PRLH_Log endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Physical Record Lock: Release Rec BDH
;
; var
; FileHandle,HiByteOffset,LoByteOffset,ErrCode,
; HiWordLen,LoWordLen : integer;
; ErrCode := PRLH_Rel(FileHandle,HiByteOffset,LoByteOffset,HiWordLen,
; LoWordLen:integer);
begin PRLH_Rel
push bp
mov bp,sp
push ds
lds si,[bp+x+16] ; FileHandle
mov bx,[si]
lds si,[bp+x+12] ; HiByteOffset
mov cx,[si]
lds si,[bp+x+8] ; LoByte
mov dx,[si]
lds si,[bp+x+4] ; HiWordLen
mov si,[si]
lds di,[bp+x] ; LoWordLen
mov di,[di]
mov ah,0BDH
int 21H
mov ah,0
pop ds
pop bp
ret 22
PRLH_Rel endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Physical Record Lock: Release Clr BEH
;
; var
; FileHandle,HiByteOffset,LoByteOffset,ErrCode,
; HiWordLen,LoWordLen : integer;
; ErrCode := PRLH_Rel(FileHandle,HiByteOffset,LoByteOffset,HiWordLen,
; LoWordLen:integer);
;
begin PRLH_Clr
push bp
mov bp,sp
push ds
lds si,[bp+x+16] ; FileHandle
mov bx,[si]
lds si,[bp+x+12] ; ByteOffset
mov cx,[si]
lds si,[bp+x+8]
mov dx,[si]
lds si,[bp+x+4] ; HiWordLen
mov si,[si]
lds di,[bp+x] ; LoWordLen
mov di,[di]
mov ah,0BEH
int 21H
mov ah,0
pop ds
pop bp
ret 22
PRLH_Clr endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Physical Record Lock: Log Rec FCB BFH
;
; var
; ErrCode,fcb,HiByteOffset,LoByteOffset : Integer;
; HiLockLen,LoLockLen,Flags,TimeOut : Integer;
;
; ErrCode := PRLF_Log(fcb,HiByteOffset,LoByteOffset,HiLockLen,LoLockLen,Flags,TimeOut);
;
begin PRLF_Log
push bp
mov bp,sp
push ds
lds si,[bp+x+24] ; FCB
mov dx,[si]
lds si,[bp+x+20] ; ByteOffset
mov bx,[si]
lds si,[bp+x+16]
mov cx,[si]
lds si,[bp+x+4] ; AL = Log Flags
mov ax,[si]
lds si,[bp+x+8] ; low lock length
mov di,[si]
lds si,[bp+x+12] ; hi lock length
mov si,[si]
mov bp,[bp+x] ; timeout value
mov bp,[bp]
mov ah,0BFH
int 21H
mov ah,0
pop ds
pop bp
ret 28
PRLF_Log endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Physical Record Lock: Rel Rec FCB C0H
;
; var
; ErrCode,fcb,HiByteOffset,LoByteOffset : Integer;
;
; ErrCode := PRLF_Rel(fcb,HiByteOffset,LoByteOffset);
;
begin PRLF_Rel
push bp
mov bp,sp
push ds
lds dx,[bp+x+8] ; FCB
lds si,[bp+x+4] ; ByteOffset
mov bx,[si]
lds si,[bp+x]
mov cx,[si]
mov ah,0C0H
int 21H
mov ah,0
pop ds
pop bp
ret 12
PRLF_Rel endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Physical Record Lock: Clr Rec FCB C1H
;
; var
; ErrCode,fcb,HiByteOffset,LoByteOffset : Integer;
;
; ErrCode := PRLF_clr(fcb,HiByteOffset,LoByteOffset);
;
begin PRLF_Clr
push bp
mov bp,sp
push ds
lds dx,[bp+x+8] ; FCB
lds si,[bp+x+4] ; ByteOffset
mov bx,[si]
lds si,[bp+x]
mov cx,[si]
mov ah,0C0H
int 21H
mov ah,0
pop ds
pop bp
ret 12
PRLF_Clr endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Lock Record Set C2H
;
; var
; ErrCode, Flags, TimeOut : Integer;
;
; ErrCode := PRLS_Lck(Flags,TimeOut);
;
begin PRLS_Lck
push bp
mov bp,sp
push ds
lds si,[bp+x+4] ; AL = Lock flag bits
mov ax,[si]
lds si,[bp+x] ; TimeOut Value
mov bp,[si]
mov ah,0C2h
int 21h
mov ah,0
pop ds
pop bp
ret 10
PRLS_Lck endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Release Record Set C3H
;
; var
; ErrCode : Integer;
;
; ErrCode := PRLS_Rel;
;
begin PRLS_Rel
mov ah,0C3h
int 21h
mov ah,0
ret
PRLS_Rel endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Clear Record Set C4H
;
; var
; ErrCode : Integer;
;
; errcode := PRLS_Clr;
;
begin PRLS_Clr
mov ah,0C4h
int 21h
mov ah,0
ret
PRLS_Clr endp
;--------------------------------
; Semaphores func(197) (C5H) subfunction 00h
;
; var
; RetCode,SemaValu,HiHandle,LoHandle,OpenCnt : Integer;
; Sema4 : String[n];
;
; RetCode := OpenSem(Sema4,SemaValu,HiHandle,LoHandle,OpenCnt);
;
begin OpenSem
push bp
mov bp,sp
push ds
lds dx,[bp+x+16] ; ptr to Semaphore string
; inc dx ; add 1 to get the address of the string
lds si,[bp+x+12] ; set semaphore value
mov cx,[si]
mov ax,0C500h ; set the function
int 21h
mov bh,00h
lds di,[bp+x] ; return the open count
mov [di],bx
lds di,[bp+x+4] ; return low handle
mov [di],cx
lds di,[bp+x+8] ; return high handle
mov [di],dx
mov ah,00h
pop ds
pop bp
ret 22
OpenSem endp
;--------------------------------
; Semaphores func(197) (C5H) subfunction 01h
;
; var
; RetCode,HiHandle,LoHandle,SemaValu,OpenCnt : Integer;
;
; RetCode := ExamSem(HiHandle,LoHandle,SemaValu,OpenCnt);
;
begin ExamSem
push bp
mov bp,sp
push ds
lds si,[bp+x+12] ; hi handle
mov dx,[si]
lds si,[bp+x+8] ; lo handle
mov cx,[si]
mov ax,0C501h ; set function
int 21h
lds di,[bp+x+4] ; return semaphore value
mov [di],cx
mov dh,00h
lds di,[bp+x]
mov [di],dx ; return open count
mov ah,00h
pop ds
pop bp
ret 16
ExamSem endp
;--------------------------------
; Semaphores func(197) (C5H) subfunction 02h
;
; var
; RetCode,HiHandle,LoHandle,TimeOut : Integer;
;
; RetCode := WaitSem(HiHandle,LoHandle,TimeOut);
;
begin WaitSem
push bp
mov bp,sp
push ds
lds si,[bp+x+8] ; hi handle
mov dx,[si]
lds si,[bp+x+4] ; lo handle
mov cx,[si]
lds si,[bp+x]
mov bp,[si] ; set time out
mov ax,0C502h ; set function
int 21h
mov ah,00h
pop ds
pop bp
ret 12
WaitSem endp
;--------------------------------
; Semaphores func(197) (C5H) subfunction 03h
;
; var
; RetCode,HiHandle,LoHandle : Integer;
;
; RetCode := SigSem(HiHandle,LoHandle);
;
begin SigSem