Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset ce52ae70 in mainline


Ignore:
Timestamp:
2013-09-14T15:35:04Z (8 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master
Children:
279f90f
Parents:
eabce2e
Message:

Allow size of the string printed by printf to be determined by apps

Location:
uspace/lib/c
Files:
2 edited

Legend:

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

    reabce2e rce52ae70  
    5050}
    5151
     52int vprintf_size(const char *fmt, va_list args)
     53{
     54        printf_spec_t ps = {
     55                asprintf_str_write,
     56                asprintf_wstr_write,
     57                NULL
     58        };
     59       
     60        return printf_core(fmt, &ps, args);
     61}
     62
     63int printf_size(const char *fmt, ...)
     64{
     65        va_list args;
     66        va_start(args, fmt);
     67        int ret = vprintf_size(fmt, args);
     68        va_end(args);
     69       
     70        return ret;
     71}
     72
    5273/** Allocate and print to string.
    5374 *
     
    6182int asprintf(char **strp, const char *fmt, ...)
    6283{
    63         printf_spec_t ps = {
    64                 asprintf_str_write,
    65                 asprintf_wstr_write,
    66                 NULL
    67         };
    68        
    6984        va_list args;
    7085        va_start(args, fmt);
    71        
    72         int ret = printf_core(fmt, &ps, args);
     86        int ret = vprintf_size(fmt, args);
    7387        va_end(args);
    7488       
  • uspace/lib/c/include/stdio.h

    reabce2e rce52ae70  
    124124extern int vsnprintf(char *, size_t, const char *, va_list);
    125125
     126extern int printf_size(const char *, ...)
     127    PRINTF_ATTRIBUTE(1, 2);
     128extern int vprintf_size(const char *, va_list);
     129
    126130/* File stream functions */
    127131extern FILE *fopen(const char *, const char *);
Note: See TracChangeset for help on using the changeset viewer.