source: ada-examples/shell/command_line_arguments.ads

ada-examples-4-10-branch ada-examples-4-10-2
Last change on this file was c53f12b, checked in by Joel Sherrill <joel.sherrill@…>, on 02/02/11 at 19:08:06

2011-02-02 Joel Sherrill <joel.sherrill@…>

  • commands.adb, commands.ads, rtems_shell.ads, shell.adb: Add getopt_r Package and example command.
  • command_line_arguments.adb, command_line_arguments.ads, getopt_r.adb, getopt_r.ads: New files.
  • Property mode set to 100644
File size: 749 bytes
Line 
1with Interfaces.C;          use Interfaces.C;
2with Interfaces.C.Strings;  use Interfaces.C.Strings;
3with Interfaces.C.Pointers;
4with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
5
6package Command_Line_Arguments is
7
8   type Argument_Array is array (ptrdiff_t range <>) of aliased chars_ptr;
9
10   package Argument_Vector_Package is new Pointers (
11      Index => ptrdiff_t,
12      Element => chars_ptr,
13      Element_Array => Argument_Array,
14      Default_Terminator => Null_Ptr
15   );
16
17   subtype Argument_Count_Type is ptrdiff_t;
18   subtype Argument_Vector_Type is Argument_Vector_Package.Pointer;
19
20   function Get_Argument(
21      Argv   : in Argument_Vector_Type;
22      Index  : Argument_Count_Type
23   ) return String;
24
25end Command_Line_Arguments;
Note: See TracBrowser for help on using the repository browser.