comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@adaos.worldonline.co.uk>
Subject: Re: Text_IO.End_Of_File Problem
Date: Mon, 26 Nov 2001 18:00:34 -0000
Date: 2001-11-26T18:00:34+00:00	[thread overview]
Message-ID: <9tu05r$4ua5t$1@ID-25716.news.dfncis.de> (raw)
In-Reply-To: fb75c450.0111260413.47679833@posting.google.com

Sequential_IO is definitely not what you require. What I need to know now is
how you are getting text from your POP3 server.

If you are able to read text lines from the server, like this:

   Text: String(1..1024); -- arbitrary length
   Last: Natural;
...
   Get_Line(Server,Text,Last);

with the line ends (almost certainly CRLFs) dealt with correctly, you should
have no trouble transferring to a text file, e.g.:

   loop
      if End_of_File(Server) then
         -- deal with premature termination
      end if; -- or catch End_Error
      Get_Line(Server,Text,Last);
      exit when Last=1 and Text(1)='.';
      Put_Line(Temp,Text(1..Last));
   end loop;

regardless of how many blank lines there may be. Of course this must be
preceded and followed by code that sends the right commands to the server (I
forget the commands now, I'm stretching my memory back 10 years as it is ;-)
and interprets its response codes.

Don't forget to close or reset the Temp file. E.g.:

   Close(Temp); -- after writing to it
...
   Open(Temp,In_File,Temp_Name);
   -- now process it for attachments

If your code is just getting TCP segments (rather than whole lines), I
suggest you need a buffer task to deliver actual lines to your main code.

When you come to writing out the attachments, for those which produce binary
data you will need to use Ada.Streams.Stream_IO to write out the binary
data.

Happy to give more detail on any point, if you require.

Does any of this help you?

--
Best wishes,
Nick Roberts


> > (2) WHAT do you really want to do?
> >
>
> What I really want to do is fairly trivial really (or at least should
> be), and involves downloading an email, writing it into a file, and
> then parsing the email to extract attachments etc.  Currently I'm
> downloading the email and saving it into a temporary file, and then
> later opening it to pull out the attachment.  Perhaps my real problem
> is using text_io to write POP3-type output straight to a file (it adds
> a load of superfluous line ends I guess), in which case Sequential_IO
> looks more hopeful.






  reply	other threads:[~2001-11-26 18:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-25 22:42 Text_IO.End_Of_File Problem Hambut
2001-11-26  1:53 ` Jeffrey Carter
2001-11-26 12:30   ` Hambut
2001-11-26 16:50     ` Mark Biggar
2001-11-26 13:25   ` Hambut
2001-11-26  2:15 ` Patrick Hohmeyer
2001-11-26 12:36   ` Hambut
2001-11-26  2:35 ` Nick Roberts
2001-11-26 12:13   ` Hambut
2001-11-26 18:00     ` Nick Roberts [this message]
2001-11-27  9:51       ` Hambut
replies disabled

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