home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
snppsend.zip
/
TESTDLL.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1999-04-27
|
3KB
|
84 lines
Program TestSNPPDLL;
// (C)Igor Vaskov, 1998, 1999. FIDO 2:5020/207.27, Phone (095) 466-6477
Uses Sockets,Strings,Delphi,OS2Base;
Type
TSnppUser = Record
Login,Passw : PChar;
End;
TSnppMessage = Record
VServ : Byte;
Ext_flg : Boolean;
ID : PChar;
Passw : PChar;
Rep,Del : Byte;
DateTime : TDateTime;
Text : PChar;
End;
function OpenSock(Var Sock : TSocket) : LongInt; external 'snppsend' index 1;
function ConnectSock(Var Sock : TSocket; Port : Word; HostAddr : PChar) : LongInt; external 'snppsend' index 2;
function CloseSock(Var Sock : TSocket) : LongInt; external 'snppsend' index 3;
function SNPPMsgSend(Var Sock : TSocket; User : TSnppUser; Msg : TSnppMessage) : LongInt; external 'snppsend' index 4;
Const
MaxIdent = 9;
IDent : array[1..MaxIdent] of String[4] = ('/LG:','/PS:','/ID:','/PI:','/TM:','/EX:','/VS:','/NF:','/IP:');
Var
Sock : TSocket;
rc : LongInt;
Mess : TSnppMessage;
User : TSnppUser;
Param : Array[1..MaxIdent] of String;
X : String;
i,j : Byte;
MA : Array[1..250] of Char;
FName : String;
hf : LongInt;
begin
for i:=1 to MaxIdent do
begin
X:=ParamStr(i);
Writeln(X);
if Length(X) > 0 then
begin
for j:=1 to MaxIdent do
begin
if Pos(IDent[j],X) > 0 then
Param[j]:=X+#0;
end;
end;
end;
User.Login:=@Param[1][5];
User.Passw:=@Param[2][5];
Mess.ID:=@Param[3][5];
Mess.Passw:=@Param[4][5];
Mess.DateTime:=0;
Mess.Ext_flg:=(Param[6][5] = 'T') or (Param[5][5] = 't');
Mess.VServ:=1;
if Param[7][5] = '2' then Mess.VServ:=2;
FName:=Param[8];
Delete(FName,1,4);
Mess.Text:='This is test message.';
hf:=FileOpen(FName,FILE_ARCHIVED,fmOpenRead or OPEN_SHARE_DENYNONE);
if hf > 0 then
begin
FillChar(MA[1],SizeOf(MA),0);
FileRead(hf,MA[1],SizeOf(MA));
FileClose(hf);
Mess.Text:=@MA[1];
end;
rc:=OpenSock(Sock);
if rc < 1 then Writeln('OpenSock error ',rc);
rc:=ConnectSock(Sock,444,@Param[9][5]);
if rc < 1 then Writeln('ConnectSock error ',rc);
if rc = 1 then
begin
rc:=SNPPMsgSend(Sock,User,Mess);
if rc < 1 then Writeln('SNPPMsgSend error ',rc);
end;
rc:=CloseSock(Sock);
if rc < 1 then Writeln('ColoseSock error ',rc);
end.