-- lwa_index.adb -- -- This simple test program does the equivalent of a browser directory -- index for one directory argument (if none, the current working directory). -- It creates a directory stream, reading each bucket (filename) and -- outputs the HTML index to STDOUT. -- -- Created in 1997 by Roy T. Fielding -- with Ada.Command_Line; with Onions.Buckets; with Onions.OS; with Onions.Instreams.Dir; with Onions.Instreams.HTML_Dir; with Onions.Outstreams.File; use Onions.Instreams; use Onions.Instreams.Dir; use Onions.Instreams.HTML_Dir; use Onions.Outstreams; use Onions.Outstreams.File; procedure Lwa_Index is Arg_Count : Natural; Arg_Pos : Natural := 1; Spin : Input_Pipe; Spout : Output_Pipe; Sperr : Output_Pipe; Sphat : HTML_Dir_Stream_Ptr; Blist : Onions.Buckets.Bucket_List; begin Sperr := Open (new File_Output_Stream, Stderr); Arg_Count := Ada.Command_Line.Argument_Count; if Arg_Count = 0 then Spin := Open (new Dir_Input_Stream, "."); elsif Arg_Count = 1 then Spin := Open (new Dir_Input_Stream, Ada.Command_Line.Argument (1)); else Write (Sperr, "Usage: lwa_index [ directory ]" & Onions.OS.New_Line); Close (Sperr); return; end if; -- Add the HTML directory stream filter on top of the dir stream -- Sphat := new HTML_Dir_Stream; Push (Spin, Input_Pipe (Sphat)); Spout := Open (new File_Output_Stream); loop begin Read (Spin, Blist); Write (Spout, Blist); exception when Onions.Instreams.End_Error => exit; end; end loop; Close (Spin); Close (Spout); Close (Sperr); end Lwa_Index;