Lines Matching refs:buf

133 char *put_dec_full9(char *buf, unsigned q)
157 *buf++ = (q - 10 * r) + '0'; /* 1 */
159 *buf++ = (r - 10 * q) + '0'; /* 2 */
161 *buf++ = (q - 10 * r) + '0'; /* 3 */
163 *buf++ = (r - 10 * q) + '0'; /* 4 */
165 *buf++ = (q - 10 * r) + '0'; /* 5 */
168 *buf++ = (r - 10 * q) + '0'; /* 6 */
170 *buf++ = (q - 10 * r) + '0'; /* 7 */
172 *buf++ = (r - 10 * q) + '0'; /* 8 */
173 *buf++ = q + '0'; /* 9 */
174 return buf;
183 char *put_dec_trunc8(char *buf, unsigned r)
191 *buf++ = q - 10*r;
195 *buf++ = (r - 10 * q) + '0';
197 return buf;
199 *buf++ = (q - 10 * r) + '0';
201 return buf;
203 *buf++ = (r - 10 * q) + '0';
205 return buf;
206 *buf++ = q + '0'; /* q <= 9 */
207 return buf;
232 char *put_dec(char *buf, unsigned long long n)
236 buf = put_dec_full9(buf, do_div(n, 1000*1000*1000));
238 return put_dec_full9(buf, n);
240 return put_dec_trunc8(buf, n);
249 void put_dec_full4(char *buf, unsigned q)
253 buf[0] = (q - 10 * r) + '0';
255 buf[1] = (r - 10 * q) + '0';
257 buf[2] = (q - 10 * r) + '0';
258 buf[3] = r + '0';
269 unsigned put_dec_helper4(char *buf, unsigned x)
273 put_dec_full4(buf, x - q * 10000);
283 char *put_dec(char *buf, unsigned long long n)
288 return put_dec_trunc8(buf, n);
296 q = put_dec_helper4(buf, q);
299 q = put_dec_helper4(buf+4, q);
302 q = put_dec_helper4(buf+8, q);
305 buf += 12;
307 buf = put_dec_trunc8(buf, q);
308 else while (buf[-1] == '0')
309 --buf;
311 return buf;
322 int num_to_str(char *buf, int size, unsigned long long num)
338 buf[idx] = tmp[len - idx - 1];
382 char *number(char *buf, char *end, unsigned long long num,
451 if (buf < end)
452 *buf = ' ';
453 ++buf;
458 if (buf < end)
459 *buf = sign;
460 ++buf;
465 if (buf < end)
466 *buf = '0';
467 ++buf;
470 if (buf < end)
471 *buf = ('X' | locase);
472 ++buf;
479 if (buf < end)
480 *buf = c;
481 ++buf;
486 if (buf < end)
487 *buf = '0';
488 ++buf;
492 if (buf < end)
493 *buf = tmp[i];
494 ++buf;
498 if (buf < end)
499 *buf = ' ';
500 ++buf;
503 return buf;
507 char *string(char *buf, char *end, const char *s, struct printf_spec spec)
518 if (buf < end)
519 *buf = ' ';
520 ++buf;
524 if (buf < end)
525 *buf = *s;
526 ++buf; ++s;
529 if (buf < end)
530 *buf = ' ';
531 ++buf;
534 return buf;
537 static void widen(char *buf, char *end, unsigned len, unsigned spaces)
540 if (buf >= end) /* nowhere to put anything */
542 size = end - buf;
544 memset(buf, ' ', size);
550 memmove(buf + spaces, buf, len);
552 memset(buf, ' ', spaces);
556 char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_spec spec,
584 for (n = 0; n != spec.precision; n++, buf++) {
592 if (buf < end)
593 *buf = c;
600 widen(buf - n, end, n, spaces);
601 return buf + spaces;
604 if (buf < end)
605 *buf = ' ';
606 ++buf;
609 return buf;
613 char *symbol_string(char *buf, char *end, void *ptr,
633 return string(buf, end, sym, spec);
639 return number(buf, end, value, spec);
644 char *resource_string(char *buf, char *end, struct resource *res,
748 return string(buf, end, sym, spec);
752 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
761 return buf;
765 return string(buf, end, NULL, spec);
785 for (i = 0; i < len && buf < end - 1; i++) {
786 buf = hex_byte_pack(buf, addr[i]);
788 if (buf < end && separator && i != len - 1)
789 *buf++ = separator;
792 return buf;
796 char *mac_address_string(char *buf, char *end, u8 *addr,
830 return string(buf, end, mac_addr, spec);
983 char *ip6_addr_string(char *buf, char *end, const u8 *addr,
993 return string(buf, end, ip6_addr, spec);
997 char *ip4_addr_string(char *buf, char *end, const u8 *addr,
1004 return string(buf, end, ip4_addr, spec);
1008 char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa,
1066 return string(buf, end, ip6_addr, spec);
1070 char *ip4_addr_string_sa(char *buf, char *end, const struct sockaddr_in *sa,
1101 return string(buf, end, ip4_addr, spec);
1105 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1114 return buf; /* nothing to print */
1117 return string(buf, end, NULL, spec); /* NULL pointer */
1155 string_escape_mem(addr, len, &buf, end - buf, flags, NULL);
1157 return buf;
1161 char *uuid_string(char *buf, char *end, const u8 *addr,
1204 return string(buf, end, uuid, spec);
1208 char *netdev_feature_string(char *buf, char *end, const u8 *addr,
1216 return number(buf, end, *(const netdev_features_t *)addr, spec);
1220 char *address_val(char *buf, char *end, const void *addr,
1240 return number(buf, end, num, spec);
1327 char *pointer(const char *fmt, char *buf, char *end, void *ptr,
1339 return string(buf, end, "(null)", spec);
1350 return symbol_string(buf, end, ptr, spec, fmt);
1353 return resource_string(buf, end, ptr, spec, fmt);
1355 return hex_string(buf, end, ptr, spec, fmt);
1360 return mac_address_string(buf, end, ptr, spec, fmt);
1372 return ip6_addr_string(buf, end, ptr, spec, fmt);
1374 return ip4_addr_string(buf, end, ptr, spec, fmt);
1384 return ip4_addr_string_sa(buf, end, &sa->v4, spec, fmt);
1386 return ip6_addr_string_sa(buf, end, &sa->v6, spec, fmt);
1388 return string(buf, end, "(invalid address)", spec);
1393 return escaped_string(buf, end, ptr, spec, fmt);
1395 return uuid_string(buf, end, ptr, spec, fmt);
1401 buf += vsnprintf(buf, end > buf ? end - buf : 0,
1404 return buf;
1415 return string(buf, end, "pK-error", spec);
1451 return netdev_feature_string(buf, end, ptr, spec);
1455 return address_val(buf, end, ptr, spec, fmt);
1457 return dentry_name(buf, end, ptr, spec, fmt);
1459 return dentry_name(buf, end,
1470 return number(buf, end, (unsigned long) ptr, spec);
1679 * @buf: The buffer to place the result into
1716 * number of characters written into @buf as return value
1723 int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
1734 str = buf;
1735 end = buf + size;
1737 /* Make sure end is always >= buf */
1738 if (end < buf) {
1740 size = end - buf;
1866 return str-buf;
1873 * @buf: The buffer to place the result into
1879 * the @buf not including the trailing '\0'. If @size is == 0 the function
1886 int vscnprintf(char *buf, size_t size, const char *fmt, va_list args)
1890 i = vsnprintf(buf, size, fmt, args);
1902 * @buf: The buffer to place the result into
1914 int snprintf(char *buf, size_t size, const char *fmt, ...)
1920 i = vsnprintf(buf, size, fmt, args);
1929 * @buf: The buffer to place the result into
1934 * The return value is the number of characters written into @buf not including
1938 int scnprintf(char *buf, size_t size, const char *fmt, ...)
1944 i = vscnprintf(buf, size, fmt, args);
1953 * @buf: The buffer to place the result into
1958 * into @buf. Use vsnprintf() or vscnprintf() in order to avoid
1965 int vsprintf(char *buf, const char *fmt, va_list args)
1967 return vsnprintf(buf, INT_MAX, fmt, args);
1973 * @buf: The buffer to place the result into
1978 * into @buf. Use snprintf() or scnprintf() in order to avoid
1983 int sprintf(char *buf, const char *fmt, ...)
1989 i = vsnprintf(buf, INT_MAX, fmt, args);
2126 * @buf: The buffer to place the result into
2141 * number of characters written into @buf as return value
2146 int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
2155 str = buf;
2156 end = buf + size;
2173 /* Make sure end is always >= buf */
2174 if (end < buf) {
2176 size = end - buf;
2299 return str - buf;
2330 * @buf: input buffer
2334 int vsscanf(const char *buf, const char *fmt, va_list args)
2336 const char *str = buf;
2412 *va_arg(args, int *) = str - buf;
2559 * @buf: input buffer
2563 int sscanf(const char *buf, const char *fmt, ...)
2569 i = vsscanf(buf, fmt, args);