︙ | | |
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
-
+
+
+
|
Tab_Stop,
Token,
Unix_Newline,
UTF_8,
Verbatim,
Width,
Upper_Hex,
Lower_Hex);
Lower_Hex,
Atom_List);
type Action is
(Error,
Print_Help,
Run,
Run_Base64,
Print_Atom,
Print_Atom_List,
Print_Config);
end Options;
package Getopt is new Natools.Getopt_Long (Options.Id);
function Getopt_Config return Getopt.Configuration;
|
︙ | | |
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
|
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
|
+
+
+
+
+
+
+
|
("verbatim", 'v', No_Argument, Options.Verbatim);
Result.Add_Option
("width", 'w', Required_Argument, Options.Width);
Result.Add_Option
("upper-hex", 'X', No_Argument, Options.Upper_Hex);
Result.Add_Option
("lower-hex", 'x', No_Argument, Options.Lower_Hex);
Result.Add_Option
("atom-list", No_Argument, Options.Atom_List);
return Result;
end Getopt_Config;
overriding procedure Option
(Handler : in out Callback;
Id : in Options.Id;
Argument : in String)
is
use type Options.Action;
begin
case Id is
when Options.ASCII =>
Param.Char_Encoding := SE.Printers.Pretty.ASCII;
when Options.Atom =>
if Handler.Action in Options.Run .. Options.Print_Config then
Handler.Action := Options.Print_Atom;
end if;
when Options.Atom_List =>
if Handler.Action in Options.Run .. Options.Print_Config then
Handler.Action := Options.Print_Atom_List;
end if;
when Options.Base64_Atom =>
Param.Quoted := SE.Printers.Pretty.No_Quoted;
Param.Fallback := SE.Printers.Pretty.Base64;
when Options.Base64_Expr =>
if Handler.Action in Options.Run .. Options.Print_Config then
|
︙ | | |
530
531
532
533
534
535
536
537
538
539
540
541
542
543
|
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
|
+
|
Separator := Result;
end Parse_Separator;
Printer_Direct : SE.Printers.Pretty.Stream_Printer (Output_Stream);
Base64_Output : aliased Base64_Stream (Output_Stream);
Printer_Base64 : SE.Printers.Pretty.Stream_Printer (Base64_Output'Access);
First_Atom_In_List : Boolean := True;
procedure Process
(Handler : in Callback'Class;
Input : access Ada.Streams.Root_Stream_Type'Class) is
begin
case Handler.Action is
when Options.Error | Options.Print_Help | Options.Print_Config =>
|
︙ | | |
551
552
553
554
555
556
557
558
559
560
561
562
563
564
|
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
|
+
+
+
+
+
+
+
+
+
|
if Handler.Arg_Count = 1 then
Open (Base64_Output);
end if;
Printer_Base64.Set_Parameters (Param);
Process (Printer_Base64, Input, True);
when Options.Print_Atom =>
Printer_Direct.Set_Parameters (Param);
Process (Printer_Direct, Input, False);
when Options.Print_Atom_List =>
if First_Atom_In_List then
Printer_Direct.Open_List;
First_Atom_In_List := False;
end if;
Printer_Direct.Set_Parameters (Param);
Process (Printer_Direct, Input, False);
end case;
end Process;
procedure Process
|
︙ | | |
626
627
628
629
630
631
632
633
634
635
636
637
638
639
|
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
|
+
+
+
+
+
|
& "Assume ASCII encoding of output");
when Options.Atom =>
New_Line (Output);
Put_Line (Output, Indent & Indent
& "Treat intputs as individual atoms");
when Options.Atom_List =>
New_Line (Output);
Put_Line (Output, Indent & Indent
& "Treat intputs as a list of individual atoms");
when Options.Base64_Expr =>
New_Line (Output);
Put_Line (Output, Indent & Indent
& "Output the expression in base-64 encoding");
when Options.Base64_Atom =>
New_Line (Output);
|
︙ | | |
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
|
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
|
-
+
+
+
+
+
+
|
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
Print_Help (Opt_Config, Ada.Text_IO.Current_Error);
when Options.Print_Help =>
Print_Help (Opt_Config, Ada.Text_IO.Current_Output);
when Options.Print_Config =>
Printer_Direct.Set_Parameters (Param);
SE.Printers.Pretty.Config.Print (Printer_Direct, To_Print);
when Options.Run .. Options.Print_Atom =>
when Options.Run .. Options.Print_Atom_List =>
if Handler.Arg_Count = 0 then
Handler.Argument ("-");
end if;
if Options."=" (Handler.Action, Options.Run_Base64) then
Close (Base64_Output);
elsif Options."=" (Handler.Action, Options.Print_Atom_List) then
if First_Atom_In_List then
Printer_Direct.Open_List;
end if;
Printer_Direct.Close_List;
end if;
end case;
end Sxcat;
|