- chcnt += printtype(lp->lstat.st_mode);
- return(chcnt);
-}
-
-#define NCACHE 64 /* power of 2 */
-#define LSMASK NCACHE - 1 /* bits to store with */
-printowner(uid)
- uid_t uid;
-{
- static struct ncache {
- uid_t uid;
- char name[UT_NAMESIZE];
- } c_uid[NCACHE];
- register struct passwd *pw;
- register struct ncache *cp;
-
- cp = c_uid + (uid & LSMASK);
- if (cp->uid != uid || !*cp->name) {
- /* if can't find owner, print out number instead */
- if (!(pw = getpwuid(uid))) {
- (void)printf("%-*u ", UT_NAMESIZE, uid);
- return;
- }
- cp->uid = uid;
- (void)strncpy(cp->name, pw->pw_name, UT_NAMESIZE);
- }
- (void)printf("%-*.*s ", UT_NAMESIZE, UT_NAMESIZE, cp->name);
-}
-
-printgrp(gid)
- gid_t gid;
-{
- static struct ncache {
- gid_t gid;
- char name[UT_NAMESIZE];
- } c_gid[NCACHE];
- register struct group *gr;
- register struct ncache *cp;
-
- cp = c_gid + (gid & LSMASK);
- if (cp->gid != gid || !*cp->name) {
- /* can't find group, print out number instead */
- if (!(gr = getgrgid(gid))) {
- (void)printf("%-*u ", UT_NAMESIZE, gid);
- return;
- }
- cp->gid = gid;
- (void)strncpy(cp->name, gr->gr_name, UT_NAMESIZE);
- }
- (void)printf("%-*.*s ", UT_NAMESIZE, UT_NAMESIZE, cp->name);