2 * Copyright (c) 2002 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the NetBSD
19 * Foundation, Inc. and its contributors.
20 * 4. Neither the name of The NetBSD Foundation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
25 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
26 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
27 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
28 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
37 #include <sys/cdefs.h>
40 __RCSID("$NetBSD: stat.c,v 1.13 2003/07/25 03:21:17 atatat Exp $");
44 __FBSDID("$FreeBSD$");
48 #else /* HAVE_CONFIG_H */
49 #define HAVE_STRUCT_STAT_ST_FLAGS 1
50 #define HAVE_STRUCT_STAT_ST_GEN 1
51 #define HAVE_STRUCT_STAT_ST_BIRTHTIME 1
52 #define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
53 #define HAVE_DEVNAME 1
54 #endif /* HAVE_CONFIG_H */
56 #include <sys/param.h>
57 #include <sys/types.h>
72 #if HAVE_STRUCT_STAT_ST_FLAGS
75 #define SHELL_F " st_flags=%f"
76 #else /* HAVE_STRUCT_STAT_ST_FLAGS */
80 #endif /* HAVE_STRUCT_STAT_ST_FLAGS */
82 #if HAVE_STRUCT_STAT_ST_BIRTHTIME
83 #define DEF_B "\"%SB\" "
85 #define SHELL_B "st_birthtime=%B "
86 #else /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
90 #endif /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
92 #if HAVE_STRUCT_STAT_ST_ATIM
93 #define st_atimespec st_atim
94 #define st_ctimespec st_ctim
95 #define st_mtimespec st_mtim
96 #endif /* HAVE_STRUCT_STAT_ST_ATIM */
99 "%d %i %Sp %l %Su %Sg %r %z \"%Sa\" \"%Sm\" \"%Sc\" " DEF_B \
101 #define RAW_FORMAT "%d %i %#p %l %u %g %r %z %a %m %c " RAW_B \
103 #define LS_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%SY"
104 #define LSF_FORMAT "%Sp %l %Su %Sg %Z %Sm %N%T%SY"
105 #define SHELL_FORMAT \
106 "st_dev=%d st_ino=%i st_mode=%#p st_nlink=%l " \
107 "st_uid=%u st_gid=%g st_rdev=%r st_size=%z " \
108 "st_atime=%a st_mtime=%m st_ctime=%c " SHELL_B \
109 "st_blksize=%k st_blocks=%b" SHELL_F
110 #define LINUX_FORMAT \
112 " Size: %-11z FileType: %HT%n" \
113 " Mode: (%OMp%03OLp/%.10Sp) Uid: (%5u/%8Su) Gid: (%5g/%8Sg)%n" \
114 "Device: %Hd,%Ld Inode: %i Links: %l%n" \
119 #define TIME_FORMAT "%b %e %T %Y"
121 #define FLAG_POUND 0x01
122 #define FLAG_SPACE 0x02
123 #define FLAG_PLUS 0x04
124 #define FLAG_ZERO 0x08
125 #define FLAG_MINUS 0x10
128 * These format characters must all be unique, except the magic one.
130 #define FMT_MAGIC '%'
133 #define SIMPLE_NEWLINE 'n'
134 #define SIMPLE_TAB 't'
135 #define SIMPLE_PERCENT '%'
136 #define SIMPLE_NUMBER '@'
138 #define FMT_POUND '#'
139 #define FMT_SPACE ' '
142 #define FMT_MINUS '-'
144 #define FMT_DECIMAL 'D'
145 #define FMT_OCTAL 'O'
146 #define FMT_UNSIGNED 'U'
148 #define FMT_FLOAT 'F'
149 #define FMT_STRING 'S'
151 #define FMTF_DECIMAL 0x01
152 #define FMTF_OCTAL 0x02
153 #define FMTF_UNSIGNED 0x04
154 #define FMTF_HEX 0x08
155 #define FMTF_FLOAT 0x10
156 #define FMTF_STRING 0x20
158 #define HIGH_PIECE 'H'
159 #define MIDDLE_PIECE 'M'
160 #define LOW_PIECE 'L'
162 #define SHOW_st_dev 'd'
163 #define SHOW_st_ino 'i'
164 #define SHOW_st_mode 'p'
165 #define SHOW_st_nlink 'l'
166 #define SHOW_st_uid 'u'
167 #define SHOW_st_gid 'g'
168 #define SHOW_st_rdev 'r'
169 #define SHOW_st_atime 'a'
170 #define SHOW_st_mtime 'm'
171 #define SHOW_st_ctime 'c'
172 #define SHOW_st_btime 'B'
173 #define SHOW_st_size 'z'
174 #define SHOW_st_blocks 'b'
175 #define SHOW_st_blksize 'k'
176 #define SHOW_st_flags 'f'
177 #define SHOW_st_gen 'v'
178 #define SHOW_symlink 'Y'
179 #define SHOW_filetype 'T'
180 #define SHOW_filename 'N'
181 #define SHOW_sizerdev 'Z'
183 void usage(const char *);
184 void output(const struct stat *, const char *,
185 const char *, int, int, int);
186 int format1(const struct stat *, /* stat info */
187 const char *, /* the file name */
188 const char *, int, /* the format string itself */
189 char *, size_t, /* a place to put the output */
190 int, int, int, int, /* the parsed format */
192 #if HAVE_STRUCT_STAT_ST_FLAGS
193 char *xfflagstostr(unsigned long);
199 #define addchar(s, c, nl) \
201 (void)fputc((c), (s)); \
202 (*nl) = ((c) == '\n'); \
203 } while (0/*CONSTCOND*/)
206 main(int argc, char *argv[])
209 int ch, rc, errs, am_readlink;
210 int lsF, fmtchar, usestat, fn, nonl, quiet;
211 char *statfmt, *options, *synopsis;
212 char dname[sizeof _PATH_DEV + SPECNAMELEN] = _PATH_DEV;
225 if (strcmp(getprogname(), "readlink") == 0) {
228 synopsis = "[-n] [file ...]";
233 options = "f:FlLnqrst:x";
234 synopsis = "[-FlLnqrsx] [-f format] [-t timefmt] [file ...]";
237 while ((ch = getopt(argc, argv, options)) != -1)
259 errx(1, "can't use format '%c' with '%c'",
274 if (fmtchar == '\0') {
279 statfmt = DEF_FORMAT;
283 if (lsF && fmtchar != 'l')
284 errx(1, "can't use format '%c' with -F", fmtchar);
288 /* statfmt already set */
291 statfmt = lsF ? LSF_FORMAT : LS_FORMAT;
294 statfmt = RAW_FORMAT;
297 statfmt = SHELL_FORMAT;
300 statfmt = LINUX_FORMAT;
310 timefmt = TIME_FORMAT;
315 if (fdevname_r(STDIN_FILENO, dname +
316 sizeof _PATH_DEV - 1, SPECNAMELEN) != NULL)
320 rc = fstat(STDIN_FILENO, &st);
324 rc = stat(file, &st);
326 rc = lstat(file, &st);
333 warn("%s: stat", file);
336 output(&st, file, statfmt, fn, nonl, quiet);
343 return (am_readlink ? linkfail : errs);
346 #if HAVE_STRUCT_STAT_ST_FLAGS
348 * fflagstostr() wrapper that leaks only once
351 xfflagstostr(unsigned long fflags)
353 static char *str = NULL;
358 str = fflagstostr(fflags);
360 err(1, "fflagstostr");
363 #endif /* HAVE_STRUCT_STAT_ST_FLAGS */
366 usage(const char *synopsis)
369 (void)fprintf(stderr, "usage: %s %s\n", getprogname(), synopsis);
374 * Parses a format string.
377 output(const struct stat *st, const char *file,
378 const char *statfmt, int fn, int nonl, int quiet)
380 int flags, size, prec, ofmt, hilo, what;
386 while (*statfmt != '\0') {
389 * Non-format characters go straight out.
391 if (*statfmt != FMT_MAGIC) {
392 addchar(stdout, *statfmt, &nl);
398 * The current format "substring" starts here,
399 * and then we skip the magic.
405 * Some simple one-character "formats".
409 addchar(stdout, '\n', &nl);
413 addchar(stdout, '\t', &nl);
417 addchar(stdout, '%', &nl);
420 case SIMPLE_NUMBER: {
423 snprintf(num, sizeof(num), "%d", fn);
424 for (p = &num[0]; *p; p++)
425 addchar(stdout, *p, &nl);
432 * This must be an actual format string. Format strings are
433 * similar to printf(3) formats up to a point, and are of
436 * % required start of format
437 * [-# +0] opt. format characters
438 * size opt. field width
439 * . opt. decimal separator, followed by
440 * prec opt. precision
441 * fmt opt. output specifier (string, numeric, etc.)
442 * sub opt. sub field specifier (high, middle, low)
443 * datum required field specifier (size, mode, etc)
445 * Only the % and the datum selector are required. All data
446 * have reasonable default output forms. The "sub" specifier
447 * only applies to certain data (mode, dev, rdev, filetype).
448 * The symlink output defaults to STRING, yet will only emit
449 * the leading " -> " if STRING is explicitly specified. The
450 * sizerdev datum will generate rdev output for character or
451 * block devices, and size output for all others.
455 if (*statfmt == FMT_POUND)
457 else if (*statfmt == FMT_SPACE)
459 else if (*statfmt == FMT_PLUS)
461 else if (*statfmt == FMT_ZERO)
463 else if (*statfmt == FMT_MINUS)
468 } while (1/*CONSTCOND*/);
471 if (isdigit((unsigned)*statfmt)) {
473 while (isdigit((unsigned)*statfmt)) {
474 size = (size * 10) + (*statfmt - '0');
482 if (*statfmt == FMT_DOT) {
486 while (isdigit((unsigned)*statfmt)) {
487 prec = (prec * 10) + (*statfmt - '0');
494 #define fmtcase(x, y) case (y): (x) = (y); statfmt++; break
495 #define fmtcasef(x, y, z) case (y): (x) = (z); statfmt++; break
497 fmtcasef(ofmt, FMT_DECIMAL, FMTF_DECIMAL);
498 fmtcasef(ofmt, FMT_OCTAL, FMTF_OCTAL);
499 fmtcasef(ofmt, FMT_UNSIGNED, FMTF_UNSIGNED);
500 fmtcasef(ofmt, FMT_HEX, FMTF_HEX);
501 fmtcasef(ofmt, FMT_FLOAT, FMTF_FLOAT);
502 fmtcasef(ofmt, FMT_STRING, FMTF_STRING);
509 fmtcase(hilo, HIGH_PIECE);
510 fmtcase(hilo, MIDDLE_PIECE);
511 fmtcase(hilo, LOW_PIECE);
518 fmtcase(what, SHOW_st_dev);
519 fmtcase(what, SHOW_st_ino);
520 fmtcase(what, SHOW_st_mode);
521 fmtcase(what, SHOW_st_nlink);
522 fmtcase(what, SHOW_st_uid);
523 fmtcase(what, SHOW_st_gid);
524 fmtcase(what, SHOW_st_rdev);
525 fmtcase(what, SHOW_st_atime);
526 fmtcase(what, SHOW_st_mtime);
527 fmtcase(what, SHOW_st_ctime);
528 fmtcase(what, SHOW_st_btime);
529 fmtcase(what, SHOW_st_size);
530 fmtcase(what, SHOW_st_blocks);
531 fmtcase(what, SHOW_st_blksize);
532 fmtcase(what, SHOW_st_flags);
533 fmtcase(what, SHOW_st_gen);
534 fmtcase(what, SHOW_symlink);
535 fmtcase(what, SHOW_filetype);
536 fmtcase(what, SHOW_filename);
537 fmtcase(what, SHOW_sizerdev);
546 subfmt, statfmt - subfmt,
548 flags, size, prec, ofmt, hilo, what);
550 for (i = 0; i < t && i < sizeof(buf); i++)
551 addchar(stdout, buf[i], &nl);
556 errx(1, "%.*s: bad format",
557 (int)(statfmt - subfmt + 1), subfmt);
561 (void)fputc('\n', stdout);
562 (void)fflush(stdout);
566 * Arranges output according to a single parsed format substring.
569 format1(const struct stat *st,
571 const char *fmt, int flen,
572 char *buf, size_t blen,
573 int flags, int size, int prec, int ofmt,
577 char *sdata, lfmt[24], tmp[20];
578 char smode[12], sid[12], path[PATH_MAX + 4];
581 const struct timespec *tsp;
584 int l, small, formats;
591 * First, pick out the data and tweak it based on hilo or
592 * specified output format (symlink output only).
597 small = (sizeof(st->st_dev) == 4);
598 data = (what == SHOW_st_dev) ? st->st_dev : st->st_rdev;
600 sdata = (what == SHOW_st_dev) ?
601 devname(st->st_dev, S_IFBLK) :
603 S_ISCHR(st->st_mode) ? S_IFCHR :
604 S_ISBLK(st->st_mode) ? S_IFBLK :
608 #endif /* HAVE_DEVNAME */
609 if (hilo == HIGH_PIECE) {
613 else if (hilo == LOW_PIECE) {
614 data = minor((unsigned)data);
617 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
620 #else /* HAVE_DEVNAME */
622 #endif /* HAVE_DEVNAME */
624 ofmt = FMTF_UNSIGNED;
627 small = (sizeof(st->st_ino) == 4);
630 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
632 ofmt = FMTF_UNSIGNED;
635 small = (sizeof(st->st_mode) == 4);
637 strmode(st->st_mode, smode);
640 if (sdata[l - 1] == ' ')
642 if (hilo == HIGH_PIECE) {
648 else if (hilo == MIDDLE_PIECE) {
649 data = (data >> 9) & 07;
654 else if (hilo == LOW_PIECE) {
660 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
666 small = (sizeof(st->st_dev) == 4);
669 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
671 ofmt = FMTF_UNSIGNED;
674 small = (sizeof(st->st_uid) == 4);
676 if ((pw = getpwuid(st->st_uid)) != NULL)
679 snprintf(sid, sizeof(sid), "(%ld)", (long)st->st_uid);
682 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
685 ofmt = FMTF_UNSIGNED;
688 small = (sizeof(st->st_gid) == 4);
690 if ((gr = getgrgid(st->st_gid)) != NULL)
693 snprintf(sid, sizeof(sid), "(%ld)", (long)st->st_gid);
696 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
699 ofmt = FMTF_UNSIGNED;
702 tsp = &st->st_atimespec;
706 tsp = &st->st_mtimespec;
710 tsp = &st->st_ctimespec;
712 #if HAVE_STRUCT_STAT_ST_BIRTHTIME
715 tsp = &st->st_birthtimespec;
716 #endif /* HAVE_STRUCT_STAT_ST_BIRTHTIME */
717 ts = *tsp; /* copy so we can muck with it */
718 small = (sizeof(ts.tv_sec) == 4);
721 tm = localtime(&ts.tv_sec);
722 (void)strftime(path, sizeof(path), timefmt, tm);
724 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
725 FMTF_FLOAT | FMTF_STRING;
730 small = (sizeof(st->st_size) == 4);
733 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
735 ofmt = FMTF_UNSIGNED;
738 small = (sizeof(st->st_blocks) == 4);
739 data = st->st_blocks;
741 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
743 ofmt = FMTF_UNSIGNED;
745 case SHOW_st_blksize:
746 small = (sizeof(st->st_blksize) == 4);
747 data = st->st_blksize;
749 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
751 ofmt = FMTF_UNSIGNED;
753 #if HAVE_STRUCT_STAT_ST_FLAGS
755 small = (sizeof(st->st_flags) == 4);
757 sdata = xfflagstostr(st->st_flags);
760 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX |
763 ofmt = FMTF_UNSIGNED;
765 #endif /* HAVE_STRUCT_STAT_ST_FLAGS */
766 #if HAVE_STRUCT_STAT_ST_GEN
768 small = (sizeof(st->st_gen) == 4);
771 formats = FMTF_DECIMAL | FMTF_OCTAL | FMTF_UNSIGNED | FMTF_HEX;
773 ofmt = FMTF_UNSIGNED;
775 #endif /* HAVE_STRUCT_STAT_ST_GEN */
779 if (S_ISLNK(st->st_mode)) {
780 snprintf(path, sizeof(path), " -> ");
781 l = readlink(file, path + 4, sizeof(path) - 4 - 1);
788 sdata = path + (ofmt == FMTF_STRING ? 0 : 4);
794 formats = FMTF_STRING;
803 if (hilo == 0 || hilo == LOW_PIECE) {
804 switch (st->st_mode & S_IFMT) {
805 case S_IFIFO: (void)strcat(sdata, "|"); break;
806 case S_IFDIR: (void)strcat(sdata, "/"); break;
809 (S_IXUSR | S_IXGRP | S_IXOTH))
810 (void)strcat(sdata, "*");
812 case S_IFLNK: (void)strcat(sdata, "@"); break;
813 case S_IFSOCK: (void)strcat(sdata, "="); break;
815 case S_IFWHT: (void)strcat(sdata, "%"); break;
818 case S_IFDOOR: (void)strcat(sdata, ">"); break;
819 #endif /* S_IFDOOR */
823 else if (hilo == HIGH_PIECE) {
824 switch (st->st_mode & S_IFMT) {
825 case S_IFIFO: sdata = "Fifo File"; break;
826 case S_IFCHR: sdata = "Character Device"; break;
827 case S_IFDIR: sdata = "Directory"; break;
828 case S_IFBLK: sdata = "Block Device"; break;
829 case S_IFREG: sdata = "Regular File"; break;
830 case S_IFLNK: sdata = "Symbolic Link"; break;
831 case S_IFSOCK: sdata = "Socket"; break;
833 case S_IFWHT: sdata = "Whiteout File"; break;
836 case S_IFDOOR: sdata = "Door"; break;
837 #endif /* S_IFDOOR */
838 default: sdata = "???"; break;
842 formats = FMTF_STRING;
849 (void)strncpy(path, file, sizeof(path));
851 formats = FMTF_STRING;
856 if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
857 char majdev[20], mindev[20];
863 majdev, sizeof(majdev),
865 ofmt, HIGH_PIECE, SHOW_st_rdev);
869 mindev, sizeof(mindev),
871 ofmt, LOW_PIECE, SHOW_st_rdev);
872 return (snprintf(buf, blen, "%.*s,%.*s",
873 l1, majdev, l2, mindev));
881 ofmt, 0, SHOW_st_size));
885 errx(1, "%.*s: bad format", (int)flen, fmt);
889 * If a subdatum was specified but not supported, or an output
890 * format was selected that is not supported, that's an error.
892 if (hilo != 0 || (ofmt & formats) == 0)
893 errx(1, "%.*s: bad format", (int)flen, fmt);
896 * Assemble the format string for passing to printf(3).
899 (void)strcat(lfmt, "%");
900 if (flags & FLAG_POUND)
901 (void)strcat(lfmt, "#");
902 if (flags & FLAG_SPACE)
903 (void)strcat(lfmt, " ");
904 if (flags & FLAG_PLUS)
905 (void)strcat(lfmt, "+");
906 if (flags & FLAG_MINUS)
907 (void)strcat(lfmt, "-");
908 if (flags & FLAG_ZERO)
909 (void)strcat(lfmt, "0");
912 * Only the timespecs support the FLOAT output format, and that
913 * requires work that differs from the other formats.
915 if (ofmt == FMTF_FLOAT) {
917 * Nothing after the decimal point, so just print seconds.
921 (void)snprintf(tmp, sizeof(tmp), "%d", size);
922 (void)strcat(lfmt, tmp);
924 (void)strcat(lfmt, "d");
925 return (snprintf(buf, blen, lfmt, ts.tv_sec));
929 * Unspecified precision gets all the precision we have:
936 * Adjust the size for the decimal point and the digits
942 * Any leftover size that's legitimate will be used.
945 (void)snprintf(tmp, sizeof(tmp), "%d", size);
946 (void)strcat(lfmt, tmp);
948 (void)strcat(lfmt, "d");
951 * The stuff after the decimal point always needs zero
954 (void)strcat(lfmt, ".%0");
957 * We can "print" at most nine digits of precision. The
958 * rest we will pad on at the end.
960 (void)snprintf(tmp, sizeof(tmp), "%dd", prec > 9 ? 9 : prec);
961 (void)strcat(lfmt, tmp);
964 * For precision of less that nine digits, trim off the
965 * less significant figures.
967 for (; prec < 9; prec++)
971 * Use the format, and then tack on any zeroes that
972 * might be required to make up the requested precision.
974 l = snprintf(buf, blen, lfmt, ts.tv_sec, ts.tv_nsec);
975 for (; prec > 9 && l < blen; prec--, l++)
976 (void)strcat(buf, "0");
981 * Add on size and precision, if specified, to the format.
984 (void)snprintf(tmp, sizeof(tmp), "%d", size);
985 (void)strcat(lfmt, tmp);
988 (void)snprintf(tmp, sizeof(tmp), ".%d", prec);
989 (void)strcat(lfmt, tmp);
993 * String output uses the temporary sdata.
995 if (ofmt == FMTF_STRING) {
997 errx(1, "%.*s: bad format", (int)flen, fmt);
998 (void)strcat(lfmt, "s");
999 return (snprintf(buf, blen, lfmt, sdata));
1003 * Ensure that sign extension does not cause bad looking output
1006 if (small && ofmt != FMTF_DECIMAL)
1007 data = (u_int32_t)data;
1010 * The four "numeric" output forms.
1012 (void)strcat(lfmt, "ll");
1014 case FMTF_DECIMAL: (void)strcat(lfmt, "d"); break;
1015 case FMTF_OCTAL: (void)strcat(lfmt, "o"); break;
1016 case FMTF_UNSIGNED: (void)strcat(lfmt, "u"); break;
1017 case FMTF_HEX: (void)strcat(lfmt, "x"); break;
1020 return (snprintf(buf, blen, lfmt, data));