Cecko
Miloš Šula
sula@rps.cz
Pátek Říjen 19 21:27:25 CEST 2007
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;
}
------------- další část ---------------
HTML příloha byla odstraněna...
URL: http://list.hw.cz/pipermail/hw-list/attachments/20071019/8899f3f6/attachment-0002.htm
Další informace o konferenci Hw-list