comp.lang.ada
 help / color / mirror / Atom feed
From: sparre@meyer.fys.ku.dk (Jacob Sparre Andersen)
Subject: Re: Web-page|socket|my-ada-program
Date: 1997/03/04
Date: 1997-03-04T00:00:00+00:00	[thread overview]
Message-ID: <1997Mar4.140321.3543@news.nbi.dk> (raw)
In-Reply-To: Pine.SOL.3.92.970228113613.28488D-100000@lathan.dtek.chalmers.se


Markus Wahl (d95wahl@dtek.chalmers.se) wrote:
 __________
| I need to read not from st-input but from a web-page.
| How can that be done.
 ^^^^^^^^^^
If the web page is on the same machine as the program, it's just to find the
right file name, and then open the file as usual (using Ada.Text_IO.Open).

If you want to access documents through HTTP, you have two options:

1) Download the document to a temporary file using a command line HTTP client
   such as w3c. You'll have to use the C function system to do this (I will
   include an example in this message). When the document is downloaded, you
   just open, read, close, and erase the temporary file.

2) Use a binding to the wwwlib. - You might have to write the binding
   yourself.

|^^^^^^^^^^
| I have heard someone talk about sockets, but I don't know what it means.
 ^^^^^^^^^^
That's a low level UNIX(?) communication system.

Greetings,

Jacob
--
Jacob Sparre Andersen                            http://www.nbi.dk/%7Esparre/
Center for Chaos and Turbulence Studies          Phone: (+45) 39 65 53 51
The Niels Bohr Institute                                (+45) 35 32 53 05
--
MFWT - The new LEGO idea book!                 Contact: sebliss@compuserve.com
------------------------------------------------------------------------------

   procedure Download (URL       : in     String;
                       File_Name : in     String) is

      use Interfaces.C;
      use Interfaces.C.Strings;

      function system (Command : chars_ptr) return Interfaces.C.int;
      pragma Import (C, system);

      Command_In_C_Format : chars_ptr :=
        New_String ("w3c " & URL & " > " & File_Name);

      Error_Code : Interfaces.C.int := system (Command_In_C_Format);

   begin --  Download
      Free (Command_In_C_Format);

      if Error_Code /= 0 then
         Ada.Text_IO.Put_Line
           (File => Ada.Text_IO.Current_Error,
            Item => "Download: system returned " &
                    Interfaces.C.int'Image (Error_Code));
         raise System_Error;
      end if;
   end Download;

------------------------------------------------------------------------------




  reply	other threads:[~1997-03-04  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-02-28  0:00 Web-page|socket|my-ada-program Markus Wahl
1997-03-04  0:00 ` Jacob Sparre Andersen [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-03-01  0:00 Web-page|socket|my-ada-program Markus Wahl
1997-03-02  0:00 ` Web-page|socket|my-ada-program Bob Klungle
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox