Print this page
2989 Eliminate use of LOGNAME_MAX in ON
1166 useradd have warning with name more 8 chars

@@ -17,10 +17,12 @@
  * information: Portions Copyright [yyyy] [name of copyright owner]
  *
  * CDDL HEADER END
  */
 /*
+ * Copyright (c) 2013 Gary Mills
+ *
  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  *
  * Portions Copyright 2009 Chad Mynhier
  */

@@ -104,11 +106,11 @@
 
 void
 Usage()
 {
         (void) fprintf(stderr, gettext(
-            "Usage:\tprstat [-acHJLmrRtTvZ] [-u euidlist] [-U uidlist]\n"
+            "Usage:\tprstat [-acHJLmrRtTvWZ] [-u euidlist] [-U uidlist]\n"
             "\t[-p pidlist] [-P cpulist] [-C psrsetlist] [-h lgrouplist]\n"
             "\t[-j projidlist] [-k taskidlist] [-z zoneidlist]\n"
             "\t[-s key | -S key] [-n nprocs[,nusers]] [-d d|u]\n"
             "\t[interval [counter]]\n"));
         exit(1);

@@ -276,30 +278,45 @@
         if (priocntl(P_PID, getpid(), PC_SETPARMS, (caddr_t)&pcparms) == -1)
                 Warn(gettext("cannot enter the real time class"));
 }
 
 void
-getprojname(projid_t projid, char *str, int len, int noresolve)
+getprojname(projid_t projid, char *str, size_t len, int noresolve,
+    int trunc, size_t width)
 {
         struct project proj;
+        size_t n;
 
         if (noresolve || getprojbyid(projid, &proj, projbuf, PROJECT_BUFSZ) ==
-            NULL)
+            NULL) {
                 (void) snprintf(str, len, "%-6d", (int)projid);
+        } else {
+                n = strlen(proj.pj_name);
+                if (trunc && n > width)
+                        (void) snprintf(str, len, "%.*s%c", width - 1,
+                            proj.pj_name, '*');
         else
                 (void) snprintf(str, len, "%-28s", proj.pj_name);
+        }
 }
 
 void
-getzonename(zoneid_t zoneid, char *str, int len)
+getzonename(zoneid_t zoneid, char *str, size_t len, int trunc, size_t width)
 {
         char zone_name[ZONENAME_MAX];
+        size_t n;
 
-        if (getzonenamebyid(zoneid, zone_name, sizeof (zone_name)) < 0)
+        if (getzonenamebyid(zoneid, zone_name, sizeof (zone_name)) < 0) {
                 (void) snprintf(str, len, "%-6d", (int)zoneid);
+        } else {
+                n = strlen(zone_name);
+                if (trunc && n > width)
+                        (void) snprintf(str, len, "%.*s%c", width - 1,
+                            zone_name, '*');
         else
                 (void) snprintf(str, len, "%-28s", zone_name);
+        }
 }
 
 /*
  * Remove all unprintable characters from process name
  */