mirror of
https://github.com/vishapoberon/vipak.git
synced 2026-04-05 20:42:26 +00:00
smth
This commit is contained in:
parent
2e4b60252a
commit
e8c580bd24
4 changed files with 93 additions and 10 deletions
2
Makefile
2
Makefile
|
|
@ -2,7 +2,7 @@
|
||||||
VOC = /opt/voc/bin/voc
|
VOC = /opt/voc/bin/voc
|
||||||
|
|
||||||
all:
|
all:
|
||||||
$(VOC) -s types.Mod sockets.Mod netdb.Mod irc.Mod
|
$(VOC) -s types.Mod sockets.Mod netdb.Mod irc.Mod test.Mod -m
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm *.h
|
rm *.h
|
||||||
|
|
|
||||||
33
irc.Mod
33
irc.Mod
|
|
@ -1,5 +1,5 @@
|
||||||
MODULE irc;
|
MODULE irc;
|
||||||
IMPORT sockets, netdb, Platform, Strings, types, SYSTEM;
|
IMPORT sockets, netdb, Platform, Strings, types, Out, SYSTEM;
|
||||||
|
|
||||||
CONST strLen = 1024;
|
CONST strLen = 1024;
|
||||||
|
|
||||||
|
|
@ -19,25 +19,50 @@ VAR
|
||||||
BEGIN
|
BEGIN
|
||||||
l := SYSTEM.ADR(buf);
|
l := SYSTEM.ADR(buf);
|
||||||
r := Platform.Write(fd, l, len);
|
r := Platform.Write(fd, l, len);
|
||||||
|
IF r = -1 THEN
|
||||||
|
Out.String("write() failed."); Out.Ln;
|
||||||
|
HALT(1);
|
||||||
|
ELSE
|
||||||
|
Out.String("write() success."); Out.Ln;
|
||||||
|
END;
|
||||||
END rawWrite;
|
END rawWrite;
|
||||||
|
|
||||||
PROCEDURE connect;
|
PROCEDURE connect*;
|
||||||
VAR hints : netdb.addrInfo;
|
VAR hints : netdb.addrInfo;
|
||||||
res: netdb.PaddrInfo;
|
res: netdb.PaddrInfo;
|
||||||
tmp32 : netdb.Int32;
|
tmp32 : netdb.Int32;
|
||||||
conn : netdb.Int32;
|
conn : netdb.Int32;
|
||||||
str0, str1: ARRAY 255 OF CHAR;
|
str0, str1: ARRAY 255 OF CHAR;
|
||||||
BEGIN
|
BEGIN
|
||||||
hints.aiFamily := sockets.AfInet;
|
(*hints.aiFamily := sockets.AfInet;*)
|
||||||
|
hints.aiFamily := sockets.AfUnspec;
|
||||||
hints.aiSockType := sockets.SockStream;
|
hints.aiSockType := sockets.SockStream;
|
||||||
hints.aiFlags := 0;
|
hints.aiFlags := 0;
|
||||||
hints.aiProtocol := 0;
|
hints.aiProtocol := netdb.ipprotoTCP;
|
||||||
hints.aiAddrLen := 0;
|
hints.aiAddrLen := 0;
|
||||||
hints.aiAddr := 0; hints.aiCanonName := 0; hints.aiNext := 0;
|
hints.aiAddr := 0; hints.aiCanonName := 0; hints.aiNext := 0;
|
||||||
|
|
||||||
|
NEW(res);
|
||||||
tmp32 := netdb.getAddrInfo(host, port, hints, res);
|
tmp32 := netdb.getAddrInfo(host, port, hints, res);
|
||||||
|
IF tmp32 # 0 THEN
|
||||||
|
Out.String("getaddrinfo() failed"); Out.Ln;
|
||||||
|
HALT(1);
|
||||||
|
ELSE
|
||||||
|
Out.String("getaddrinfo() returned 0, success"); Out.Ln;
|
||||||
|
END;
|
||||||
conn := sockets.Socket(res^.aiFamily, res^.aiSockType, res^.aiProtocol);
|
conn := sockets.Socket(res^.aiFamily, res^.aiSockType, res^.aiProtocol);
|
||||||
|
IF conn = -1 THEN
|
||||||
|
Out.String("socket() returned -1, error"); Out.Ln;
|
||||||
|
HALT(1);
|
||||||
|
ELSE
|
||||||
|
Out.String("socket() succeeded."); Out.Ln;
|
||||||
|
END;
|
||||||
tmp32 := sockets.Connect(conn, res^.aiAddr, res^.aiAddrLen);
|
tmp32 := sockets.Connect(conn, res^.aiAddr, res^.aiAddrLen);
|
||||||
|
IF tmp32 = 0 THEN
|
||||||
|
Out.String("connect() succeeded."); Out.Ln;
|
||||||
|
ELSE
|
||||||
|
Out.String("connect() failed."); Out.Ln; HALT(1);
|
||||||
|
END;
|
||||||
|
|
||||||
(* "USER test 0 0 :test\r\n" *)
|
(* "USER test 0 0 :test\r\n" *)
|
||||||
(* "NICK test\r\n\000\060 :test\r\n"*)
|
(* "NICK test\r\n\000\060 :test\r\n"*)
|
||||||
|
|
|
||||||
51
netdb.Mod
51
netdb.Mod
|
|
@ -2,6 +2,57 @@ MODULE netdb;
|
||||||
|
|
||||||
IMPORT SYSTEM;
|
IMPORT SYSTEM;
|
||||||
|
|
||||||
|
CONST
|
||||||
|
ipprotoIP* = 0;
|
||||||
|
|
||||||
|
ipprotoICMP* = 1;
|
||||||
|
|
||||||
|
ipprotoIGMP* = 2;
|
||||||
|
|
||||||
|
ipprotoIPIP* = 4;
|
||||||
|
|
||||||
|
ipprotoTCP* = 6;
|
||||||
|
|
||||||
|
ipprotoEGP* = 8;
|
||||||
|
|
||||||
|
ipprotoPUP* = 12;
|
||||||
|
|
||||||
|
ipprotoUDP* = 17;
|
||||||
|
|
||||||
|
ipprotoIDP* = 22;
|
||||||
|
|
||||||
|
ipprotoTP* = 29;
|
||||||
|
|
||||||
|
ipprotoDCCP* = 33;
|
||||||
|
|
||||||
|
ipprotoIPV6* = 41;
|
||||||
|
|
||||||
|
ipprotoRSVP* = 46;
|
||||||
|
|
||||||
|
ipprotoGRE* = 47;
|
||||||
|
|
||||||
|
ipprotoESP* = 50;
|
||||||
|
|
||||||
|
ipprotoAH* = 51;
|
||||||
|
|
||||||
|
ipprotoMTP* = 92;
|
||||||
|
|
||||||
|
ipprotoBEETPH* = 94;
|
||||||
|
|
||||||
|
ipprotoENCAP* = 98;
|
||||||
|
|
||||||
|
ipprotoPIM* = 103;
|
||||||
|
|
||||||
|
ipprotoCOMP* = 108;
|
||||||
|
|
||||||
|
ipprotoSCTP* = 132;
|
||||||
|
|
||||||
|
ipprotoUDPLITE* = 136;
|
||||||
|
|
||||||
|
ipprotoMPLS* = 137;
|
||||||
|
|
||||||
|
ipprotoRAW* = 255;
|
||||||
|
|
||||||
TYPE
|
TYPE
|
||||||
Int32* = LONGINT;
|
Int32* = LONGINT;
|
||||||
Int64* = HUGEINT;
|
Int64* = HUGEINT;
|
||||||
|
|
|
||||||
15
test.Mod
15
test.Mod
|
|
@ -1,20 +1,27 @@
|
||||||
MODULE test;
|
MODULE test;
|
||||||
|
|
||||||
|
IMPORT irc;
|
||||||
|
|
||||||
VAR
|
VAR
|
||||||
|
|
||||||
botOwner, nick, serv, chan: ARRAY 32 OF CHAR;
|
owner, nick, serv, port, chan: ARRAY 32 OF CHAR;
|
||||||
|
|
||||||
PROCEDURE testBot;
|
PROCEDURE testBot;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
|
irc.nick := nick;
|
||||||
|
irc.host := serv;
|
||||||
|
irc.port := port;
|
||||||
|
irc.channel := chan;
|
||||||
|
irc.user := owner;
|
||||||
|
irc.connect;
|
||||||
END testBot;
|
END testBot;
|
||||||
|
|
||||||
BEGIN
|
BEGIN
|
||||||
botOwner := "norayr";
|
owner := "norayr";
|
||||||
nick := "norayr";
|
nick := "norayr";
|
||||||
serv := "irc.freenode.net";
|
serv := "irc.freenode.net";
|
||||||
|
port := "6667";
|
||||||
chan := "#oberon";
|
chan := "#oberon";
|
||||||
|
|
||||||
testBot;
|
testBot;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue