Cecko

jirka7a@seznam.cz jirka7a@seznam.cz
Pátek Říjen 19 21:48:47 CEST 2007


signed int byva 16 bit tj. uplne v pohode.
Jirka
  ----- Original Message ----- 
  From: Miloš Šula 
  To: hw-list@list.hw.cz 
  Sent: Friday, October 19, 2007 9:27 PM
  Subject: Cecko


  Zdravim,

  Studuji ted FAT procedury pro pristup k MMC kartam a narazil jsem na nasledujici funkci, ale nechapu jak muze vracet EOF kdyz je rozsah signed int -128 az 127 a funkce vraci binární hodnotu načteného bajtu.Jak pak poznam ze to je EOF a ne hodnota -1 ( tj po pretypovani na unsigned INT ) tj. 127. Nebo jsem to jen proste nepochopil spravne..

   

   

  Milos 

   

   

   

  EOF = -1;

  /*

  signed int fatgetc(FILE* stream)

  Summary: Gets a character from a stream.

  Param: The stream to get a character from.

  Returns: The character that was gotten from the stream,

            EOF if the stream has reached the end of the file or doesn't have permissions to read,

  */

  signed int fatgetc(FILE* stream)

  {

     char ch; // character read in

   

     // check to see if the stream has proper permissions to read

     if(stream->Flags & Read)

     {

        // when the number of bytes until eof hit zero, we know we are at the end of any file

        if(stream->Bytes_Until_EOF == 0)

        {

           stream->Flags |= EOF_Reached;

           return EOF;

        }

   

        // read in the next byte in the buffer

        if(read_buffer(stream, &ch) == EOF)

           return EOF;

   

        // a 0x00 will signify the end of a non-binary file

        if((ch == '\0') && !(stream->Flags & Binary))

        {

           stream->Flags |= EOF_Reached;

           return EOF;

        }

   

        // get the next contiguous address of the stream

        if(get_next_addr(&(stream->Cur_Char)) != GOODEC)

           return EOF;

           

        // we just got 1 byte closer to the end of the file

        stream->Bytes_Until_EOF -= 1;

        return ch;

     }

   

     // if the stream doesn't have proper permissions to read, return an EOF

     else

        return EOF;

  }



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


  _______________________________________________
  HW-list mailing list  -  sponsored by www.HW.cz
  Hw-list@list.hw.cz
  http://list.hw.cz/mailman/listinfo/hw-list
------------- další část ---------------
HTML příloha byla odstraněna...
URL: http://list.hw.cz/pipermail/hw-list/attachments/20071019/95e739c6/attachment-0002.htm 


Další informace o konferenci Hw-list