Example #1
0
/*!
 * \brief Write argument list to a stream using a given format.
 *
 * Similar to vfprintf() except that the format string is located in
 * program memory.
 *
 * \param stream Pointer to a previously opened stream.
 * \param fmt    Format string in program space containing conversion 
 *               specifications.
 * \param ap     List of arguments.
 *
 * \return The number of characters written or a negative value to
 *         indicate an error.
 */
int vfprintf_P(FILE * stream, PGM_P fmt, va_list ap)
{
    int rc;
    char *rp;
    size_t rl;

    rl = strlen_P(fmt) + 1;
    if ((rp = NutHeapAlloc(rl)) == 0)
        return -1;
    memcpy_P(rp, fmt, rl);
    rc = _putf(_write, stream->iob_fd, rp, ap);
    NutHeapFree(rp);

    return rc;
}
/*!
 * \brief Write argument list to a stream using a given format.
 *
 * \param stream Pointer to a previously opened stream.
 * \param fmt    Format string containing conversion specifications.
 * \param ap     List of arguments.
 *
 * \return The number of characters written or a negative value to
 *         indicate an error.
 */
int vfprintf(FILE * stream, CONST char *fmt, va_list ap)
{
    return _putf(_write, stream->iob_fd, fmt, ap);
}