-
Notifications
You must be signed in to change notification settings - Fork 2
/
NetHandle.pas
121 lines (105 loc) · 3.58 KB
/
NetHandle.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
unit NetHandle;
interface
{------------------------------------------------------------------------
Pointer data handler for BNet.Pas
Written by Lifepower
------------------------------------------------------------------------
*** DISCLAIMER OF WARRANTY ***
The author disclaims all warranties relating to this product,
whenever expressed or implied, including without any limitation,
any implied warranties of merchantability or fitness for a particular
purpose.
The author will not be liable for any special, incidental, consequential,
indirect or similar damages due to loss of data, damage of hardware or
any other reason, even if the author was advised of the possibility of
such loss or damage.
In other words, if any program using this unit or this unit itself will
damage or destroy your network, harm your computer and so on - I WILL NOT
BE RESPONSIBLE!
------------------------------------------------------------------------
You can use this library in any kind of software, including commercially
distributed software. Since I cannot control who and how uses this unit, I
can't force you do to so, but I ask you to put my name in credits section
if possible.
------------------------------------------------------------------------
For further information read BNet.txt file.
}
procedure AddByte(Var Buffer:Pointer;Value:Byte);
function ReadByte(Var Buffer:Pointer):Byte;
procedure AddWord(Var Buffer:Pointer;Value:Word);
function ReadWord(Var Buffer:Pointer):Word;
procedure AddInt(Var Buffer:Pointer;Value:Integer);
function ReadInt(Var Buffer:Pointer):Integer;
procedure AddCardinal(Var Buffer:Pointer;Value:Cardinal);
function ReadCardinal(Var Buffer:Pointer):Cardinal;
procedure AddSingle(Var Buffer:Pointer;Value:Single);
function ReadSingle(Var Buffer:Pointer):Single;
procedure AddString(Var Buffer:Pointer;Value:ShortString);
function ReadString(Var Buffer:Pointer):ShortString;
implementation
procedure AddByte(Var Buffer:Pointer;Value:Byte);
begin
Byte(Buffer^):=Value;
Inc(Integer(Buffer));
end;
function ReadByte(Var Buffer:Pointer):Byte;
begin
Result:=Byte(Buffer^);
Inc(Integer(Buffer));
end;
procedure AddWord(Var Buffer:Pointer;Value:Word);
begin
Word(Buffer^):=Value;
Inc(Integer(Buffer),2);
end;
function ReadWord(Var Buffer:Pointer):Word;
begin
Result:=Word(Buffer^);
Inc(Integer(Buffer),2);
end;
procedure AddInt(Var Buffer:Pointer;Value:Integer);
begin
Integer(Buffer^):=Value;
Inc(Integer(Buffer),4);
end;
function ReadInt(Var Buffer:Pointer):Integer;
begin
Result:=Integer(Buffer^);
Inc(Integer(Buffer),4);
end;
procedure AddCardinal(Var Buffer:Pointer;Value:Cardinal);
begin
Cardinal(Buffer^):=Value;
Inc(Integer(Buffer),4);
end;
function ReadCardinal(Var Buffer:Pointer):Cardinal;
begin
Result:=Cardinal(Buffer^);
Inc(Integer(Buffer),4);
end;
procedure AddSingle(Var Buffer:Pointer;Value:Single);
begin
Single(Buffer^):=Value;
Inc(Integer(Buffer),4);
end;
function ReadSingle(Var Buffer:Pointer):Single;
begin
Result:=Single(Buffer^);
Inc(Integer(Buffer),4);
end;
procedure AddString(Var Buffer:Pointer;Value:ShortString);
begin
AddByte(Buffer,Byte(Value[0]));
Move(Value[1],Buffer^,Byte(Value[0]));
Inc(Integer(Buffer),Byte(Value[0]));
end;
function ReadString(Var Buffer:Pointer):ShortString;
Var Str:ShortString;
begin
Str[0]:=Char(ReadByte(Buffer));
Move(Buffer^,Str[1],Byte(Str[0]));
Inc(Integer(Buffer),Byte(Str[0]));
Result:=Str;
end;
end.