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