text
stringlengths
0
234
if C_Setsockopt (C.Int (Obj.Fd),
C.Int (Level),
C.Int (Name),
C_Value.all'Address,
Size) < 0 then
raise Socket_Exception with "Setopt error" & Nanomsg.Errors.Errno_Text;
end if;
Free (C_Value);
end Set_Option;
function Get_Option (Obj : in Socket_T;
Level : in Nanomsg.Sockopt.Option_Level_T;
Name : in Nanomsg.Sockopt.Option_Type_T) return String is
type String_Access_T is access all String;
procedure Free is new Ada.Unchecked_Deallocation (Name => String_Access_T,
Object => String);
function Nn_Getsockopt (Socket : in C.Int;
Level : in C.Int;
Option_Name : in C.Int;
Value : in out String_Access_T;
Size : in System.Address) return C.Int
with Import, Convention => C, External_Name => "nn_getsockopt";
use Nanomsg.Sockopt;
Max_Size : constant := 63;
Ptr : String_Access_T := new String(1..Max_Size);
Size : C.Size_T := Max_Size;
use type C.Size_T;
begin
if Nn_Getsockopt (Socket => C.Int (Obj.Fd),
Level => C.Int (Level),
Option_Name => C.Int (Name),
Value => Ptr,
Size => Size'Address) < 0 then
raise Socket_Exception with "Getopt error" & Nanomsg.Errors.Errno_Text;
end if;
declare
Retval : constant String := Ptr.all(1.. Integer (Size));
begin
Free (Ptr);
return Retval;
Function Definition: function Convert is new Ada.Unchecked_Conversion (chars_ptr, Void_Ptr);
Function Body: begin
Send_Signal (Plugin, "irc_input_send", String_Type, Convert (Signal_Message));
Free (Signal_Message);
exception
when others =>
Free (Signal_Message);
raise;
end Send_Message;
function Get_Nick (Host : String) return String is
Sender : constant String := SU.To_String (Split (Host, Separator => "!", Maximum => 2) (1));
begin
return Sender (Sender'First + 1 .. Sender'Last);
end Get_Nick;
function Name (Plugin : Plugin_Ptr) return String is
(Value (Plugin.Plugin_Get_Name (Plugin)));
procedure Print (Plugin : Plugin_Ptr; Prefix : Prefix_Kind; Message : String) is
package CH renames Ada.Characters.Handling;
Prefix_String : constant chars_ptr := Plugin.Prefix (CH.To_Lower (Prefix'Image) & L1.NUL);
Message_String : constant C_String := Value (Prefix_String) & Message & L1.NUL;
begin
Plugin.Printf_Date_Tags
(System.Null_Address, 0, Null_Ptr, Message_String);
end Print;
procedure Print (Plugin : Plugin_Ptr; Prefix : String; Message : String) is
begin
Plugin.Printf_Date_Tags
(System.Null_Address, 0, Null_Ptr, Prefix & L1.HT & Message & L1.NUL);
end Print;
procedure Print (Plugin : Plugin_Ptr; Message : String) is
begin
Print (Plugin, " ", Message);
end Print;
procedure Log (Plugin : Plugin_Ptr; Message : String) is
begin
Plugin.Log_Printf (Message & L1.NUL);
end Log;
procedure Print_Error (Plugin : Plugin_Ptr; Value : Ada.Exceptions.Exception_Occurrence) is
begin
Print (Plugin, Error, Ada.Exceptions.Exception_Information (Value));
end Print_Error;
function Command_Callback
(Callback : On_Command_Callback;
Data : Data_Ptr;