]>
git.saurik.com Git - apple/libresolv.git/blob - ns_print.c
2 * Copyright (c) 1996-1999 by Internet Software Consortium.
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
9 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
10 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
11 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
13 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
14 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20 static const char rcsid
[] = "$Id: ns_print.c,v 1.1 2006/03/01 19:01:37 majka Exp $";
27 #include "port_before.h"
30 #include <sys/types.h>
31 #include <sys/socket.h>
33 #include <netinet/in.h>
34 #include <arpa/nameser.h>
35 #include <arpa/inet.h>
43 #include <isc/assertions.h>
44 #include "port_after.h"
48 # define SPRINTF(x) strlen(sprintf/**/x)
50 # define SPRINTF(x) ((size_t)sprintf x)
55 static size_t prune_origin(const char *name
, const char *origin
);
56 static int charstr(const u_char
*rdata
, const u_char
*edata
,
57 char **buf
, size_t *buflen
);
58 static int addname(const u_char
*msg
, size_t msglen
,
59 const u_char
**p
, const char *origin
,
60 char **buf
, size_t *buflen
);
61 static void addlen(size_t len
, char **buf
, size_t *buflen
);
62 static int addstr(const char *src
, size_t len
,
63 char **buf
, size_t *buflen
);
64 static int addtab(size_t len
, size_t target
, int spaced
,
65 char **buf
, size_t *buflen
);
69 #ifndef dst_s_dns_key_id
70 #define dst_s_dns_key_id res_9_dst_s_dns_key_id
72 u_int16_t
dst_s_dns_key_id(const u_char
*, const int);
86 * ns_sprintrr(handle, rr, name_ctx, origin, buf, buflen)
87 * Convert an RR to presentation format.
89 * Number of characters written to buf, or -1 (check errno).
92 ns_sprintrr(const ns_msg
*handle
, const ns_rr
*rr
,
93 const char *name_ctx
, const char *origin
,
94 char *buf
, size_t buflen
)
98 n
= ns_sprintrrf(ns_msg_base(*handle
), ns_msg_size(*handle
),
99 ns_rr_name(*rr
), ns_rr_class(*rr
), ns_rr_type(*rr
),
100 ns_rr_ttl(*rr
), ns_rr_rdata(*rr
), ns_rr_rdlen(*rr
),
101 name_ctx
, origin
, buf
, buflen
);
107 * ns_sprintrrf(msg, msglen, name, class, type, ttl, rdata, rdlen,
108 * name_ctx, origin, buf, buflen)
109 * Convert the fields of an RR into presentation format.
111 * Number of characters written to buf, or -1 (check errno).
114 ns_sprintrrf(const u_char
*msg
, size_t msglen
,
115 const char *name
, ns_class
class, ns_type type
,
116 u_long ttl
, const u_char
*rdata
, size_t rdlen
,
117 const char *name_ctx
, const char *origin
,
118 char *buf
, size_t buflen
)
120 const char *obuf
= buf
;
121 const u_char
*edata
= rdata
+ rdlen
;
131 if (name_ctx
!= NULL
&& ns_samename(name_ctx
, name
) == 1) {
132 T(addstr("\t\t\t", 3, &buf
, &buflen
));
134 len
= prune_origin(name
, origin
);
137 } else if (len
== 0) {
138 T(addstr("@\t\t\t", 4, &buf
, &buflen
));
140 T(addstr(name
, len
, &buf
, &buflen
));
141 /* Origin not used or not root, and no trailing dot? */
142 if (((origin
== NULL
|| origin
[0] == '\0') ||
143 (origin
[0] != '.' && origin
[1] != '\0' &&
144 name
[len
] == '\0')) && name
[len
- 1] != '.') {
146 T(addstr(".", 1, &buf
, &buflen
));
149 T(spaced
= addtab(len
, 24, spaced
, &buf
, &buflen
));
156 T(x
= ns_format_ttl(ttl
, buf
, buflen
));
157 addlen(x
, &buf
, &buflen
);
158 len
= SPRINTF((tmp
, " %s %s", p_class(class), p_type(type
)));
159 T(addstr(tmp
, len
, &buf
, &buflen
));
162 T(spaced
= addtab(x
+ len
, 16, spaced
, &buf
, &buflen
));
169 if (rdlen
!= NS_INADDRSZ
)
171 (void) inet_ntop(AF_INET
, rdata
, buf
, buflen
);
172 addlen(strlen(buf
), &buf
, &buflen
);
182 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
188 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
192 T(addstr(" ", 1, &buf
, &buflen
));
195 /* Second word, optional in ISDN records. */
196 if (type
== ns_t_isdn
&& rdata
== edata
)
199 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
209 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
210 T(addstr(" ", 1, &buf
, &buflen
));
212 /* Administrator name. */
213 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
214 T(addstr(" (\n", 3, &buf
, &buflen
));
217 if ((edata
- rdata
) != 5*NS_INT32SZ
)
221 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
222 T(addstr("\t\t\t\t\t", 5, &buf
, &buflen
));
223 len
= SPRINTF((tmp
, "%lu", t
));
224 T(addstr(tmp
, len
, &buf
, &buflen
));
225 T(spaced
= addtab(len
, 16, spaced
, &buf
, &buflen
));
226 T(addstr("; serial\n", 9, &buf
, &buflen
));
229 /* Refresh interval. */
230 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
231 T(addstr("\t\t\t\t\t", 5, &buf
, &buflen
));
232 T(len
= ns_format_ttl(t
, buf
, buflen
));
233 addlen(len
, &buf
, &buflen
);
234 T(spaced
= addtab(len
, 16, spaced
, &buf
, &buflen
));
235 T(addstr("; refresh\n", 10, &buf
, &buflen
));
238 /* Retry interval. */
239 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
240 T(addstr("\t\t\t\t\t", 5, &buf
, &buflen
));
241 T(len
= ns_format_ttl(t
, buf
, buflen
));
242 addlen(len
, &buf
, &buflen
);
243 T(spaced
= addtab(len
, 16, spaced
, &buf
, &buflen
));
244 T(addstr("; retry\n", 8, &buf
, &buflen
));
248 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
249 T(addstr("\t\t\t\t\t", 5, &buf
, &buflen
));
250 T(len
= ns_format_ttl(t
, buf
, buflen
));
251 addlen(len
, &buf
, &buflen
);
252 T(spaced
= addtab(len
, 16, spaced
, &buf
, &buflen
));
253 T(addstr("; expiry\n", 9, &buf
, &buflen
));
257 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
258 T(addstr("\t\t\t\t\t", 5, &buf
, &buflen
));
259 T(len
= ns_format_ttl(t
, buf
, buflen
));
260 addlen(len
, &buf
, &buflen
);
261 T(addstr(" )", 2, &buf
, &buflen
));
262 T(spaced
= addtab(len
, 16, spaced
, &buf
, &buflen
));
263 T(addstr("; minimum\n", 10, &buf
, &buflen
));
273 if (rdlen
< NS_INT16SZ
)
279 len
= SPRINTF((tmp
, "%u ", t
));
280 T(addstr(tmp
, len
, &buf
, &buflen
));
283 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
291 if (rdlen
< NS_INT16SZ
)
297 len
= SPRINTF((tmp
, "%u ", t
));
298 T(addstr(tmp
, len
, &buf
, &buflen
));
301 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
302 T(addstr(" ", 1, &buf
, &buflen
));
305 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
311 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
318 while (rdata
< edata
) {
319 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
324 T(addstr(" ", 1, &buf
, &buflen
));
331 (void) inet_nsap_ntoa(rdlen
, rdata
, t
);
332 T(addstr(t
, strlen(t
), &buf
, &buflen
));
337 if (rdlen
!= NS_IN6ADDRSZ
)
339 (void) inet_ntop(AF_INET6
, rdata
, buf
, buflen
);
340 addlen(strlen(buf
), &buf
, &buflen
);
346 /* XXX protocol format checking? */
347 (void) loc_ntoa(rdata
, t
);
348 T(addstr(t
, strlen(t
), &buf
, &buflen
));
353 u_int order
, preference
;
356 if (rdlen
< 2*NS_INT16SZ
)
359 /* Order, Precedence. */
360 order
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
361 preference
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
362 len
= SPRINTF((t
, "%u %u ", order
, preference
));
363 T(addstr(t
, len
, &buf
, &buflen
));
366 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
370 T(addstr(" ", 1, &buf
, &buflen
));
373 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
377 T(addstr(" ", 1, &buf
, &buflen
));
380 T(len
= charstr(rdata
, edata
, &buf
, &buflen
));
386 T(addstr(" ", 1, &buf
, &buflen
));
389 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
394 u_int priority
, weight
, port
;
397 if (rdlen
< NS_INT16SZ
*3)
400 /* Priority, Weight, Port. */
401 priority
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
402 weight
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
403 port
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
404 len
= SPRINTF((t
, "%u %u %u ", priority
, weight
, port
));
405 T(addstr(t
, len
, &buf
, &buflen
));
408 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
415 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
416 T(addstr(" ", 1, &buf
, &buflen
));
419 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
426 if (rdlen
< NS_INT32SZ
+ 1)
430 (void) inet_ntop(AF_INET
, rdata
, buf
, buflen
);
431 addlen(strlen(buf
), &buf
, &buflen
);
432 rdata
+= NS_INADDRSZ
;
435 len
= SPRINTF((tmp
, " %u ( ", *rdata
));
436 T(addstr(tmp
, len
, &buf
, &buflen
));
442 while (rdata
< edata
) {
447 T(addstr("\n\t\t\t\t", 5,
452 len
= SPRINTF((tmp
, "%d ", n
));
453 T(addstr(tmp
, len
, &buf
, &buflen
));
459 T(addstr(")", 1, &buf
, &buflen
));
465 char base64_key
[NS_MD5RSA_MAX_BASE64
];
466 u_int keyflags
, protocol
, algorithm
, key_id
;
470 if (rdlen
< NS_INT16SZ
+ NS_INT8SZ
+ NS_INT8SZ
)
473 /* Key flags, Protocol, Algorithm. */
474 key_id
= dst_s_dns_key_id(rdata
, edata
-rdata
);
475 keyflags
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
477 algorithm
= *rdata
++;
478 len
= SPRINTF((tmp
, "0x%04x %u %u",
479 keyflags
, protocol
, algorithm
));
480 T(addstr(tmp
, len
, &buf
, &buflen
));
482 /* Public key data. */
483 len
= b64_ntop(rdata
, edata
- rdata
,
484 base64_key
, sizeof base64_key
);
488 T(addstr(" (", 2, &buf
, &buflen
));
493 for (n
= 0; n
< len
; n
+= 48) {
494 T(addstr(leader
, strlen(leader
), &buf
, &buflen
));
495 T(addstr(base64_key
+ n
, MIN(len
- n
, 48),
499 T(addstr(" )", 2, &buf
, &buflen
));
500 n
= SPRINTF((tmp
, " ; key_tag= %u", key_id
));
501 T(addstr(tmp
, n
, &buf
, &buflen
));
507 char base64_key
[NS_MD5RSA_MAX_BASE64
];
508 u_int type
, algorithm
, labels
, footprint
;
516 /* Type covered, Algorithm, Label count, Original TTL. */
517 type
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
518 algorithm
= *rdata
++;
520 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
521 len
= SPRINTF((tmp
, "%s %d %d %lu ",
522 p_type(type
), algorithm
, labels
, t
));
523 T(addstr(tmp
, len
, &buf
, &buflen
));
524 if (labels
> (u_int
)dn_count_labels(name
))
527 /* Signature expiry. */
528 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
529 len
= SPRINTF((tmp
, "%s ", p_secstodate(t
)));
530 T(addstr(tmp
, len
, &buf
, &buflen
));
533 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
534 len
= SPRINTF((tmp
, "%s ", p_secstodate(t
)));
535 T(addstr(tmp
, len
, &buf
, &buflen
));
537 /* Signature Footprint. */
538 footprint
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
539 len
= SPRINTF((tmp
, "%u ", footprint
));
540 T(addstr(tmp
, len
, &buf
, &buflen
));
543 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
546 len
= b64_ntop(rdata
, edata
- rdata
,
547 base64_key
, sizeof base64_key
);
549 T(addstr(" (", 2, &buf
, &buflen
));
556 for (n
= 0; n
< len
; n
+= 48) {
557 T(addstr(leader
, strlen(leader
), &buf
, &buflen
));
558 T(addstr(base64_key
+ n
, MIN(len
- n
, 48),
562 T(addstr(" )", 2, &buf
, &buflen
));
569 /* Next domain name. */
570 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
574 for (c
= 0; c
< n
*8; c
++)
575 if (NS_NXT_BIT_ISSET(c
, rdata
)) {
576 len
= SPRINTF((tmp
, " %s", p_type(c
)));
577 T(addstr(tmp
, len
, &buf
, &buflen
));
583 u_int c_type
, key_tag
, alg
;
586 char base64_cert
[8192], tmp
[40];
589 c_type
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
590 key_tag
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
591 alg
= (u_int
) *rdata
++;
593 len
= SPRINTF((tmp
, "%d %d %d ", c_type
, key_tag
, alg
));
594 T(addstr(tmp
, len
, &buf
, &buflen
));
595 siz
= (edata
-rdata
)*4/3 + 4; /* "+4" accounts for trailing \0 */
596 if (siz
> sizeof(base64_cert
) * 3/4) {
597 const char *str
= "record too long to print";
598 T(addstr(str
, strlen(str
), &buf
, &buflen
));
601 len
= b64_ntop(rdata
, edata
-rdata
, base64_cert
, siz
);
606 T(addstr(" (", 2, &buf
, &buflen
));
613 for (n
= 0; n
< len
; n
+= 48) {
614 T(addstr(leader
, strlen(leader
),
616 T(addstr(base64_cert
+ n
, MIN(len
- n
, 48),
620 T(addstr(" )", 2, &buf
, &buflen
));
626 /* KJD - need to complete this */
628 int mode
, err
, keysize
;
630 /* Algorithm name. */
631 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
632 T(addstr(" ", 1, &buf
, &buflen
));
635 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
636 len
= SPRINTF((tmp
, "%s ", p_secstodate(t
)));
637 T(addstr(tmp
, len
, &buf
, &buflen
));
640 t
= ns_get32(rdata
); rdata
+= NS_INT32SZ
;
641 len
= SPRINTF((tmp
, "%s ", p_secstodate(t
)));
642 T(addstr(tmp
, len
, &buf
, &buflen
));
644 /* Mode , Error, Key Size. */
645 /* Priority, Weight, Port. */
646 mode
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
647 err
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
648 keysize
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
649 len
= SPRINTF((tmp
, "%u %u %u ", mode
, err
, keysize
));
650 T(addstr(tmp
, len
, &buf
, &buflen
));
652 /* needs to dump key, print otherdata length & other data */
656 /* BEW - need to complete this */
659 T(len
= addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
660 T(addstr(" ", 1, &buf
, &buflen
));
661 rdata
+= 8; /* time */
662 n
= ns_get16(rdata
); rdata
+= NS_INT16SZ
;
663 rdata
+= n
; /* sig */
664 n
= ns_get16(rdata
); rdata
+= NS_INT16SZ
; /* original id */
665 sprintf(buf
, "%d", ns_get16(rdata
));
667 addlen(strlen(buf
), &buf
, &buflen
);
676 if (rdlen
== 0) goto formerr
;
677 len
= SPRINTF((tmp
, "%d ", *rdata
));
678 T(addstr(tmp
, len
, &buf
, &buflen
));
680 if (pbit
> 128) goto formerr
;
681 pbyte
= (pbit
& ~7) / 8;
684 /* address suffix: provided only when prefix len != 128 */
686 if (rdata
+ pbyte
>= edata
) goto formerr
;
687 memset(&a
, 0, sizeof(a
));
688 memcpy(&a
.s6_addr
[pbyte
], rdata
, sizeof(a
) - pbyte
);
689 (void) inet_ntop(AF_INET6
, &a
, buf
, buflen
);
690 addlen(strlen(buf
), &buf
, &buflen
);
691 rdata
+= sizeof(a
) - pbyte
;
694 /* prefix name: provided only when prefix len > 0 */
697 if (rdata
>= edata
) goto formerr
;
698 T(addstr(" ", 1, &buf
, &buflen
));
699 T(addname(msg
, msglen
, &rdata
, origin
, &buf
, &buflen
));
705 len
= SPRINTF((tmp
, "%u bytes", class));
706 T(addstr(tmp
, len
, &buf
, &buflen
));
711 comment
= "unknown RR type";
716 comment
= "RR format error";
721 len
= SPRINTF((tmp
, "\\# %u (\t; %s", (unsigned int)(edata
- rdata
), comment
));
722 T(addstr(tmp
, len
, &buf
, &buflen
));
723 while (rdata
< edata
) {
725 p
+= SPRINTF((p
, "\n\t"));
727 n
= MIN(16, edata
- rdata
);
728 for (m
= 0; m
< n
; m
++)
729 p
+= SPRINTF((p
, "%02x ", rdata
[m
]));
730 T(addstr(tmp
, p
- tmp
, &buf
, &buflen
));
732 T(addstr(")", 1, &buf
, &buflen
));
733 T(addtab(p
- tmp
+ 1, 48, spaced
, &buf
, &buflen
));
736 p
+= SPRINTF((p
, "; "));
737 for (m
= 0; m
< n
; m
++)
738 *p
++ = (isascii(rdata
[m
]) && isprint(rdata
[m
]))
741 T(addstr(tmp
, p
- tmp
, &buf
, &buflen
));
752 * prune_origin(name, origin)
753 * Find out if the name is at or under the current origin.
755 * Number of characters in name before start of origin,
756 * or length of name if origin does not match.
758 * This function should share code with samedomain().
761 prune_origin(const char *name
, const char *origin
) {
762 const char *oname
= name
;
764 while (*name
!= '\0') {
765 if (origin
!= NULL
&& ns_samename(name
, origin
) == 1)
766 return (name
- oname
- (name
> oname
));
767 while (*name
!= '\0') {
770 /* XXX need to handle \nnn form. */
773 } else if (*name
== '.') {
780 return (name
- oname
);
785 * charstr(rdata, edata, buf, buflen)
786 * Format a <character-string> into the presentation buffer.
788 * Number of rdata octets consumed
789 * 0 for protocol format error
790 * -1 for output buffer error
792 * buffer is advanced on success.
795 charstr(const u_char
*rdata
, const u_char
*edata
, char **buf
, size_t *buflen
) {
796 const u_char
*odata
= rdata
;
797 size_t save_buflen
= *buflen
;
798 char *save_buf
= *buf
;
800 if (addstr("\"", 1, buf
, buflen
) < 0)
805 if (rdata
+ 1 + n
<= edata
) {
808 if (strchr("\n\"\\", *rdata
) != NULL
)
809 if (addstr("\\", 1, buf
, buflen
) < 0)
811 if (addstr((const char *)rdata
, 1,
818 if (addstr("\"", 1, buf
, buflen
) < 0)
820 return (rdata
- odata
);
824 *buflen
= save_buflen
;
829 addname(const u_char
*msg
, size_t msglen
,
830 const u_char
**pp
, const char *origin
,
831 char **buf
, size_t *buflen
)
833 size_t newlen
, save_buflen
= *buflen
;
834 char *save_buf
= *buf
;
837 n
= dn_expand(msg
, msg
+ msglen
, *pp
, *buf
, *buflen
);
839 goto enospc
; /* Guess. */
840 newlen
= prune_origin(*buf
, origin
);
843 } else if (newlen
== 0) {
844 /* Use "@" instead of name. */
845 if (newlen
+ 2 > *buflen
)
846 goto enospc
; /* No room for "@\0". */
847 (*buf
)[newlen
++] = '@';
848 (*buf
)[newlen
] = '\0';
850 if (((origin
== NULL
|| origin
[0] == '\0') ||
851 (origin
[0] != '.' && origin
[1] != '\0' &&
852 (*buf
)[newlen
] == '\0')) && (*buf
)[newlen
- 1] != '.') {
853 /* No trailing dot. */
855 if (newlen
+ 2 > *buflen
)
856 goto enospc
; /* No room for ".\0". */
857 (*buf
)[newlen
++] = '.';
858 (*buf
)[newlen
] = '\0';
862 addlen(newlen
, buf
, buflen
);
868 *buflen
= save_buflen
;
873 addlen(size_t len
, char **buf
, size_t *buflen
) {
875 if (len
> *buflen
) return;
877 INSIST(len
<= *buflen
);
884 addstr(const char *src
, size_t len
, char **buf
, size_t *buflen
) {
885 if (len
>= *buflen
) {
889 memcpy(*buf
, src
, len
);
890 addlen(len
, buf
, buflen
);
896 addtab(size_t len
, size_t target
, int spaced
, char **buf
, size_t *buflen
) {
897 size_t save_buflen
= *buflen
;
898 char *save_buf
= *buf
;
901 if (spaced
|| len
>= target
- 1) {
902 T(addstr(" ", 2, buf
, buflen
));
905 for (t
= (target
- len
- 1) / 8; t
>= 0; t
--)
906 if (addstr("\t", 1, buf
, buflen
) < 0) {
907 *buflen
= save_buflen
;