From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8f01d35116e753b6 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.205.119.5 with SMTP id fs5mr2485979bkc.7.1332877445364; Tue, 27 Mar 2012 12:44:05 -0700 (PDT) Path: h15ni56245bkw.0!nntp.google.com!news2.google.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: xor Date: Tue, 27 Mar 2012 21:44:00 +0200 Organization: cbb software GmbH Message-ID: References: <9t8mq9Fla4U1@mid.individual.net> <9t99r9F6e2U1@mid.individual.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: Gbl624r6iuNIccy3ASy5ag.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-03-27T21:44:00+02:00 List-Id: On Tue, 27 Mar 2012 21:09:02 +0100, Michael Moeller wrote: > I have to read in what in C is called an unsigned byte, C does not have it. [unsigned] char maybe? In Ada there is a type Unsigned_8 declared in the package Interfaces. > which in fact is > a stream of bytes without any interpretation as a symbol. That depends on the operating system and the file type. > In addition it would be nice to call something like 'fstat' to get the > size of file in advance instead of checking every byte for EOF. In Ada you don't need that. You just read file until End_Error exception is propagated. This is more efficient (no look ahead) and more portable too. Here is an example of reading out a file in Ada using stream interface: http://rosettacode.org/wiki/Bitmap/Read_a_PPM_file#Ada It uses Character type, which is close to the way one programs in C. Character'Pos (x), where x is of Character is a number 0..255. You can also use Interfaces.Unsigned_8 instead of Character, no difference. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de