[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[avr-libc-dev] Usage of 'FILE *' in base put/get seems doubtful

From: Dmitry K.
Subject: [avr-libc-dev] Usage of 'FILE *' in base put/get seems doubtful
Date: Sun, 11 Sep 2005 13:36:10 +1100
User-agent: KMail/1.5

Hi all.

Now (Avr-libc 1.2.5 and previous) it is possible to appoint different
i/o functions to different streams, for example:
    uart0_stream = fdevopen (uart0_put, 0, 0);
    uart1_stream = fdevopen (uart1_put, 0, 0);
At desire different functions can be united in one, for example: 
    int uart0_put (char c)
        return uartX_put (c, 0);
    int uart1_put (char c)
        return uartX_put (c, 1);
Whether can somebody result a simple example, where the new parameter
('FILE *') would be really useful?

   On the other hand, transfer 'FILE *' in function of more low level,
than library 'stdio', seems illogical. Whether it is possible to execute,
for example, 'fclose' inside 'uart_put'?  Or, for example: 
    int uart_put (char c, FILE *fp)
        fputc (c, fp);
        return 0;
        fdevopen (uart_put, ...);
And in general, whether is though one function with parameter 'FILE *'
which is safe for using in this case? Actually, transferring 'FILE *'
unknown function, the library 'stdio' loses the control over the
integrity.  ('const FILE *' - it would be better).

   The library 'Glibc' has the similar mechanism -- fopencookie.
But here in the subroutine of the low level the pointer which was
established by the user at opening a file - 'void *' is transferred
not 'FILE *', and. This pointer is not used in any way in


reply via email to

[Prev in Thread] Current Thread [Next in Thread]