raw
ffa_ch4_ffacalc.kv      1 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 2 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 3 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
ffa_ch4_ffacalc.kv 4 -- --
ffa_ch14_barrett.kv 5 -- (C) 2018 Stanislav Datskovskiy ( www.loper-os.org ) --
ffa_ch4_ffacalc.kv 6 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
ffa_ch4_ffacalc.kv 7 -- --
ffa_ch4_ffacalc.kv 8 -- You do not have, nor can you ever acquire the right to use, copy or --
ffa_ch4_ffacalc.kv 9 -- distribute this software ; Should you use this software for any purpose, --
ffa_ch4_ffacalc.kv 10 -- or copy and distribute it to anyone or in any manner, you are breaking --
ffa_ch4_ffacalc.kv 11 -- the laws of whatever soi-disant jurisdiction, and you promise to --
ffa_ch4_ffacalc.kv 12 -- continue doing so for the indefinite future. In any case, please --
ffa_ch4_ffacalc.kv 13 -- always : read and understand any software ; verify any PGP signatures --
ffa_ch4_ffacalc.kv 14 -- that you use - for any purpose. --
ffa_ch4_ffacalc.kv 15 -- --
ffa_ch4_ffacalc.kv 16 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
ffa_ch4_ffacalc.kv 17 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 18 ------------------------------------------------------------------------------
ffa_ch4_ffacalc.kv 19
ffa_ch4_ffacalc.kv 20 with System; use System;
ffa_ch4_ffacalc.kv 21
ffa_ch4_ffacalc.kv 22 package body CmdLine is
ffa_ch4_ffacalc.kv 23
ffa_ch4_ffacalc.kv 24 -- Test if GNAT's cmdline mechanism is available
ffa_ch4_ffacalc.kv 25 function Initialized return Boolean is
ffa_ch4_ffacalc.kv 26 gnat_argv : System.Address;
ffa_ch4_ffacalc.kv 27 pragma Import (C, gnat_argv, "gnat_argv");
ffa_ch4_ffacalc.kv 28
ffa_ch4_ffacalc.kv 29 begin
ffa_ch4_ffacalc.kv 30 return gnat_argv /= System.Null_Address;
ffa_ch4_ffacalc.kv 31 end Initialized;
ffa_ch4_ffacalc.kv 32
ffa_ch4_ffacalc.kv 33
ffa_ch4_ffacalc.kv 34 -- Fill the provided string with the text of Number-th cmdline arg
ffa_ch4_ffacalc.kv 35 procedure Get_Argument(Number : in Natural;
ffa_ch14_barrett.kv 36 Result : out CmdLineArg) is
ffa_ch4_ffacalc.kv 37 begin
ffa_ch4_ffacalc.kv 38 if Number >= Arg_Count or (not Initialized) then
ffa_ch4_ffacalc.kv 39 raise Constraint_Error;
ffa_ch4_ffacalc.kv 40 end if;
ffa_ch4_ffacalc.kv 41
ffa_ch4_ffacalc.kv 42 declare
ffa_ch4_ffacalc.kv 43 L : constant Integer := Len_Arg(Number);
ffa_ch4_ffacalc.kv 44 Arg : aliased String(1 .. L);
ffa_ch4_ffacalc.kv 45 begin
ffa_ch4_ffacalc.kv 46 -- Will it fit into the available space?
ffa_ch4_ffacalc.kv 47 if L > Result'Length then
ffa_ch4_ffacalc.kv 48 raise Constraint_Error;
ffa_ch4_ffacalc.kv 49 end if;
ffa_ch4_ffacalc.kv 50
ffa_ch4_ffacalc.kv 51 -- Get this arg string from where GNAT stowed it
ffa_ch4_ffacalc.kv 52 Fill_Arg(Arg'Address, Number);
ffa_ch4_ffacalc.kv 53
ffa_ch4_ffacalc.kv 54 -- Copy it to Result:
ffa_ch4_ffacalc.kv 55 Result := (others => ' ');
ffa_ch4_ffacalc.kv 56 Result(Arg'Range) := Arg;
ffa_ch4_ffacalc.kv 57 end;
ffa_ch4_ffacalc.kv 58 end Get_Argument;
ffa_ch4_ffacalc.kv 59
ffa_ch4_ffacalc.kv 60 end CmdLine;