Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/asprintf.c

    r163e34c r694ca3d6  
    4040#include <str.h>
    4141#include <printf_core.h>
     42
     43static int asprintf_str_write(const char *str, size_t count, void *unused)
     44{
     45        return str_nlength(str, count);
     46}
     47
     48static int asprintf_wstr_write(const char32_t *str, size_t count, void *unused)
     49{
     50        return wstr_nlength(str, count);
     51}
     52
     53int vprintf_length(const char *fmt, va_list args)
     54{
     55        printf_spec_t ps = {
     56                asprintf_str_write,
     57                asprintf_wstr_write,
     58                NULL
     59        };
     60
     61        return printf_core(fmt, &ps, args);
     62}
     63
     64int printf_length(const char *fmt, ...)
     65{
     66        va_list args;
     67        va_start(args, fmt);
     68        int ret = vprintf_length(fmt, args);
     69        va_end(args);
     70
     71        return ret;
     72}
    4273
    4374/** Allocate and print to string.
     
    84115        int ret = vasprintf(strp, fmt, args);
    85116        va_end(args);
     117
    86118        return ret;
    87119}
Note: See TracChangeset for help on using the changeset viewer.