Lines Matching refs:spec

383 	     struct printf_spec spec)
391 int need_pfx = ((spec.flags & SPECIAL) && spec.base != 10);
397 locase = (spec.flags & SMALL);
398 if (spec.flags & LEFT)
399 spec.flags &= ~ZEROPAD;
401 if (spec.flags & SIGN) {
405 spec.field_width--;
406 } else if (spec.flags & PLUS) {
408 spec.field_width--;
409 } else if (spec.flags & SPACE) {
411 spec.field_width--;
415 if (spec.base == 16)
416 spec.field_width -= 2;
418 spec.field_width--;
423 if (num < spec.base)
430 else if (spec.base != 10) { /* 8 or 16 */
431 int mask = spec.base - 1;
434 if (spec.base == 16)
445 if (i > spec.precision)
446 spec.precision = i;
448 spec.field_width -= spec.precision;
449 if (!(spec.flags & (ZEROPAD+LEFT))) {
450 while (--spec.field_width >= 0) {
464 if (spec.base == 16 || !is_zero) {
469 if (spec.base == 16) {
476 if (!(spec.flags & LEFT)) {
477 char c = (spec.flags & ZEROPAD) ? '0' : ' ';
478 while (--spec.field_width >= 0) {
485 while (i <= --spec.precision) {
497 while (--spec.field_width >= 0) {
507 char *string(char *buf, char *end, const char *s, struct printf_spec spec)
514 len = strnlen(s, spec.precision);
516 if (!(spec.flags & LEFT)) {
517 while (len < spec.field_width--) {
528 while (len < spec.field_width--) {
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++) {
596 if (n < spec.field_width) {
598 unsigned spaces = spec.field_width - n;
599 if (!(spec.flags & LEFT)) {
614 struct printf_spec spec, const char *fmt)
633 return string(buf, end, sym, spec);
635 spec.field_width = 2 * sizeof(void *);
636 spec.flags |= SPECIAL | SMALL | ZEROPAD;
637 spec.base = 16;
639 return number(buf, end, value, spec);
645 struct printf_spec spec, const char *fmt)
748 return string(buf, end, sym, spec);
752 char *hex_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
759 if (spec.field_width == 0)
765 return string(buf, end, NULL, spec);
782 if (spec.field_width > 0)
783 len = min_t(int, spec.field_width, 64);
797 struct printf_spec spec, const char *fmt)
830 return string(buf, end, mac_addr, spec);
984 struct printf_spec spec, const char *fmt)
993 return string(buf, end, ip6_addr, spec);
998 struct printf_spec spec, const char *fmt)
1004 return string(buf, end, ip4_addr, spec);
1009 struct printf_spec spec, const char *fmt)
1053 p = number(p, pend, ntohs(sa->sin6_port), spec);
1058 IPV6_FLOWINFO_MASK), spec);
1062 p = number(p, pend, sa->sin6_scope_id, spec);
1066 return string(buf, end, ip6_addr, spec);
1071 struct printf_spec spec, const char *fmt)
1097 p = number(p, pend, ntohs(sa->sin_port), spec);
1101 return string(buf, end, ip4_addr, spec);
1105 char *escaped_string(char *buf, char *end, u8 *addr, struct printf_spec spec,
1113 if (spec.field_width == 0)
1117 return string(buf, end, NULL, spec); /* NULL pointer */
1152 len = spec.field_width < 0 ? 1 : spec.field_width;
1162 struct printf_spec spec, const char *fmt)
1204 return string(buf, end, uuid, spec);
1209 struct printf_spec spec)
1211 spec.flags |= SPECIAL | SMALL | ZEROPAD;
1212 if (spec.field_width == -1)
1213 spec.field_width = 2 + 2 * sizeof(netdev_features_t);
1214 spec.base = 16;
1216 return number(buf, end, *(const netdev_features_t *)addr, spec);
1221 struct printf_spec spec, const char *fmt)
1225 spec.flags |= SPECIAL | SMALL | ZEROPAD;
1226 spec.base = 16;
1231 spec.field_width = sizeof(dma_addr_t) * 2 + 2;
1236 spec.field_width = sizeof(phys_addr_t) * 2 + 2;
1240 return number(buf, end, num, spec);
1328 struct printf_spec spec)
1330 int default_width = 2 * sizeof(void *) + (spec.flags & SPECIAL ? 2 : 0);
1337 if (spec.field_width == -1)
1338 spec.field_width = default_width;
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);
1413 if (spec.field_width == -1)
1414 spec.field_width = default_width;
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);
1461 spec, fmt);
1463 spec.flags |= SMALL;
1464 if (spec.field_width == -1) {
1465 spec.field_width = default_width;
1466 spec.flags |= ZEROPAD;
1468 spec.base = 16;
1470 return number(buf, end, (unsigned long) ptr, spec);
1494 int format_decode(const char *fmt, struct printf_spec *spec)
1499 if (spec->type == FORMAT_TYPE_WIDTH) {
1500 if (spec->field_width < 0) {
1501 spec->field_width = -spec->field_width;
1502 spec->flags |= LEFT;
1504 spec->type = FORMAT_TYPE_NONE;
1509 if (spec->type == FORMAT_TYPE_PRECISION) {
1510 if (spec->precision < 0)
1511 spec->precision = 0;
1513 spec->type = FORMAT_TYPE_NONE;
1518 spec->type = FORMAT_TYPE_NONE;
1530 spec->flags = 0;
1538 case '-': spec->flags |= LEFT; break;
1539 case '+': spec->flags |= PLUS; break;
1540 case ' ': spec->flags |= SPACE; break;
1541 case '#': spec->flags |= SPECIAL; break;
1542 case '0': spec->flags |= ZEROPAD; break;
1551 spec->field_width = -1;
1554 spec->field_width = skip_atoi(&fmt);
1557 spec->type = FORMAT_TYPE_WIDTH;
1563 spec->precision = -1;
1567 spec->precision = skip_atoi(&fmt);
1568 if (spec->precision < 0)
1569 spec->precision = 0;
1572 spec->type = FORMAT_TYPE_PRECISION;
1579 spec->qualifier = -1;
1582 spec->qualifier = *fmt++;
1583 if (unlikely(spec->qualifier == *fmt)) {
1584 if (spec->qualifier == 'l') {
1585 spec->qualifier = 'L';
1587 } else if (spec->qualifier == 'h') {
1588 spec->qualifier = 'H';
1595 spec->base = 10;
1598 spec->type = FORMAT_TYPE_CHAR;
1602 spec->type = FORMAT_TYPE_STR;
1606 spec->type = FORMAT_TYPE_PTR;
1611 spec->type = FORMAT_TYPE_PERCENT_CHAR;
1616 spec->base = 8;
1620 spec->flags |= SMALL;
1623 spec->base = 16;
1628 spec->flags |= SIGN;
1642 spec->type = FORMAT_TYPE_INVALID;
1646 if (spec->qualifier == 'L')
1647 spec->type = FORMAT_TYPE_LONG_LONG;
1648 else if (spec->qualifier == 'l') {
1649 if (spec->flags & SIGN)
1650 spec->type = FORMAT_TYPE_LONG;
1652 spec->type = FORMAT_TYPE_ULONG;
1653 } else if (_tolower(spec->qualifier) == 'z') {
1654 spec->type = FORMAT_TYPE_SIZE_T;
1655 } else if (spec->qualifier == 't') {
1656 spec->type = FORMAT_TYPE_PTRDIFF;
1657 } else if (spec->qualifier == 'H') {
1658 if (spec->flags & SIGN)
1659 spec->type = FORMAT_TYPE_BYTE;
1661 spec->type = FORMAT_TYPE_UBYTE;
1662 } else if (spec->qualifier == 'h') {
1663 if (spec->flags & SIGN)
1664 spec->type = FORMAT_TYPE_SHORT;
1666 spec->type = FORMAT_TYPE_USHORT;
1668 if (spec->flags & SIGN)
1669 spec->type = FORMAT_TYPE_INT;
1671 spec->type = FORMAT_TYPE_UINT;
1727 struct printf_spec spec = {0};
1745 int read = format_decode(fmt, &spec);
1749 switch (spec.type) {
1762 spec.field_width = va_arg(args, int);
1766 spec.precision = va_arg(args, int);
1772 if (!(spec.flags & LEFT)) {
1773 while (--spec.field_width > 0) {
1784 while (--spec.field_width > 0) {
1793 str = string(str, end, va_arg(args, char *), spec);
1798 spec);
1816 switch (spec.type) {
1827 if (spec.flags & SIGN)
1854 str = number(str, end, num, spec);
2022 struct printf_spec spec = {0};
2049 int read = format_decode(fmt, &spec);
2053 switch (spec.type) {
2090 switch (spec.type) {
2148 struct printf_spec spec = {0};
2181 int read = format_decode(fmt, &spec);
2185 switch (spec.type) {
2198 spec.field_width = get_arg(int);
2202 spec.precision = get_arg(int);
2208 if (!(spec.flags & LEFT)) {
2209 while (--spec.field_width > 0) {
2219 while (--spec.field_width > 0) {
2230 str = string(str, end, (char *)str_arg, spec);
2235 str = pointer(fmt+1, str, end, get_arg(void *), spec);
2250 switch (spec.type) {
2284 str = number(str, end, num, spec);
2286 } /* switch(spec.type) */