Cecko

Ales Prochaska prochaska@alsoft.cz
Pátek Říjen 19 21:52:52 CEST 2007


Normálně se to dělá tak, že se vrací nějaký "signed 16" typ. Byte se
rozšíří, přičaruje se k němu 257. hodnota, pak se to testuje a pak se
to zase ořízne na byte... Za některé programátorské techniky by se měl
zpětně odebírat diplom a nemá-li jej dotyčný pachatel, pak mu soudně
nařídit navštěvování schůzek Anonymous Software Engineers.

Aleš Procháska

>     
>   
>   
> 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ší informace o konferenci Hw-list