Rev 2071 | Rev 2479 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2071 | Rev 2209 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | size_t size; /* total space for string */ |
41 | size_t size; /* total space for string */ |
42 | size_t len; /* count of currently used characters */ |
42 | size_t len; /* count of currently used characters */ |
43 | char *string; /* destination string */ |
43 | char *string; /* destination string */ |
44 | }; |
44 | }; |
45 | 45 | ||
46 | int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data); |
- | |
47 | - | ||
48 | /** Write string to given buffer. |
46 | /** Write string to given buffer. |
49 | * Write at most data->size characters including trailing zero. According to C99 has snprintf to return number |
47 | * Write at most data->size characters including trailing zero. According to C99 has snprintf to return number |
50 | * of characters that would have been written if enough space had been available. Hence the return value is not |
48 | * of characters that would have been written if enough space had been available. Hence the return value is not |
51 | * number of really printed characters but size of input string. Number of really used characters |
49 | * number of really printed characters but size of input string. Number of really used characters |
52 | * is stored in data->len. |
50 | * is stored in data->len. |
53 | * @param str source string to print |
51 | * @param str source string to print |
54 | * @param count size of source string |
52 | * @param count size of source string |
55 | * @param data structure with destination string, counter of used space and total string size. |
53 | * @param data structure with destination string, counter of used space and total string size. |
56 | * @return number of characters to print (not characters really printed!) |
54 | * @return number of characters to print (not characters really printed!) |
57 | */ |
55 | */ |
58 | int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) |
56 | static int vsnprintf_write(const char *str, size_t count, struct vsnprintf_data *data) |
59 | { |
57 | { |
60 | size_t i; |
58 | size_t i; |
61 | i = data->size - data->len; |
59 | i = data->size - data->len; |
62 | 60 | ||
63 | if (i == 0) { |
61 | if (i == 0) { |