6
PMyMsgBuf = ^TMyMsgBuf;
12
Procedure DoError (Const Msg : string);
15
Writeln (msg,'returned an error : ',ipcerror);
19
Procedure SendMessage (Id : Longint;
22
Const MText : String);
25
Writeln ('Sending message.');
28
If not msgsnd(Id,PMsgBuf(@Buf),256,0) then
32
Procedure ReadMessage (ID : Longint;
37
Writeln ('Reading message.');
39
If msgrcv(ID,PMSGBuf(@Buf),256,mtype,0) then
40
Writeln ('Type : ',buf.mtype,' Text : ',buf.mtext)
45
Procedure RemoveQueue ( ID : Longint);
48
If msgctl (id,IPC_RMID,Nil) then
49
Writeln ('Removed Queue with id',Id);
52
Procedure ChangeQueueMode (ID,mode : longint);
54
Var QueueDS : TMSQid_ds;
57
If Not msgctl (Id,IPC_STAT,@QueueDS) then
58
DoError ('msgctl : stat');
59
Writeln ('Old permissions : ',QueueDS.msg_perm.mode);
60
QueueDS.msg_perm.mode:=Mode;
61
if msgctl (ID,IPC_SET,@QueueDS) then
62
Writeln ('New permissions : ',QueueDS.msg_perm.mode)
64
DoError ('msgctl : IPC_SET');
70
Writeln ('Usage : msgtool s(end) <type> <text> (max 255 characters)');
71
Writeln (' r(eceive) <type>');
72
Writeln (' d(elete)');
73
Writeln (' m(ode) <decimal mode>');
77
Function StrToInt (S : String): longint;
84
If C<>0 Then DoError ('StrToInt : '+S);
94
If Paramcount<1 then Usage;
96
ID:=msgget(key,IPC_CREAT or 438);
97
If ID<0 then DoError ('MsgGet');
98
Case upCase(Paramstr(1)[1]) of
99
'S' : If ParamCount<>3 then
102
SendMessage (id,Buf,StrToInt(Paramstr(2)),paramstr(3));
103
'R' : If ParamCount<>2 then
106
ReadMessage (id,buf,strtoint(Paramstr(2)));
107
'D' : If ParamCount<>1 then
111
'M' : If ParamCount<>2 then
114
ChangeQueueMode (id,strtoint(paramstr(2)));
b'\\ No newline at end of file'