-
+ EE9AD64E37CFC68344AFE8F1D5DFA4683B808E7D4719B16D1B5605661C9736AE7D99631C97FCC55F03416A2DF6D717216884E34612080C3F7C887E3EA00FF903
ffa/ffacalc/cmdline.adb
(0 . 0)(1 . 60)
50 ------------------------------------------------------------------------------
51 ------------------------------------------------------------------------------
52 -- This file is part of 'Finite Field Arithmetic', aka 'FFA'. --
53 -- --
54 -- (C) 2017 Stanislav Datskovskiy ( www.loper-os.org ) --
55 -- http://wot.deedbot.org/17215D118B7239507FAFED98B98228A001ABFFC7.html --
56 -- --
57 -- You do not have, nor can you ever acquire the right to use, copy or --
58 -- distribute this software ; Should you use this software for any purpose, --
59 -- or copy and distribute it to anyone or in any manner, you are breaking --
60 -- the laws of whatever soi-disant jurisdiction, and you promise to --
61 -- continue doing so for the indefinite future. In any case, please --
62 -- always : read and understand any software ; verify any PGP signatures --
63 -- that you use - for any purpose. --
64 -- --
65 -- See also http://trilema.com/2015/a-new-software-licensing-paradigm . --
66 ------------------------------------------------------------------------------
67 ------------------------------------------------------------------------------
68
69 with System; use System;
70
71 package body CmdLine is
72
73 -- Test if GNAT's cmdline mechanism is available
74 function Initialized return Boolean is
75 gnat_argv : System.Address;
76 pragma Import (C, gnat_argv, "gnat_argv");
77
78 begin
79 return gnat_argv /= System.Null_Address;
80 end Initialized;
81
82
83 -- Fill the provided string with the text of Number-th cmdline arg
84 procedure Get_Argument(Number : in Natural;
85 Result : out String) is
86 begin
87 if Number >= Arg_Count or (not Initialized) then
88 raise Constraint_Error;
89 end if;
90
91 declare
92 L : constant Integer := Len_Arg(Number);
93 Arg : aliased String(1 .. L);
94 begin
95 -- Will it fit into the available space?
96 if L > Result'Length then
97 raise Constraint_Error;
98 end if;
99
100 -- Get this arg string from where GNAT stowed it
101 Fill_Arg(Arg'Address, Number);
102
103 -- Copy it to Result:
104 Result := (others => ' ');
105 Result(Arg'Range) := Arg;
106 end;
107 end Get_Argument;
108
109 end CmdLine;