------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. -- -- -- -- (C) 2018 Stanislav Datskovskiy ( www.loper-os.org ) -- -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html -- -- -- -- You do not have, nor can you ever acquire the right to use, copy or -- -- distribute this software ; Should you use this software for any purpose, -- -- or copy and distribute it to anyone or in any manner, you are breaking -- -- the laws of whatever soi-disant jurisdiction, and you promise to -- -- continue doing so for the indefinite future. In any case, please -- -- always : read and understand any software ; verify any PGP signatures -- -- that you use - for any purpose. -- -- -- -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . -- ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with System; use System; package body CmdLine is -- Test if GNAT's cmdline mechanism is available function Initialized return Boolean is gnat_argv : System.Address; pragma Import (C, gnat_argv, "gnat_argv"); begin return gnat_argv /= System.Null_Address; end Initialized; -- Fill the provided string with the text of Number-th cmdline arg procedure Get_Argument(Number : in Natural; Result : out CmdLineArg) is begin if Number >= Arg_Count or (not Initialized) then raise Constraint_Error; end if; declare L : constant Integer := Len_Arg(Number); Arg : aliased String(1 .. L); begin -- Will it fit into the available space? if L > Result'Length then raise Constraint_Error; end if; -- Get this arg string from where GNAT stowed it Fill_Arg(Arg'Address, Number); -- Copy it to Result: Result := (others => ' '); Result(Arg'Range) := Arg; end; end Get_Argument; end CmdLine;