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
*/
@@ -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 termcap, 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 (termcap && 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 termcap, 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 (termcap && 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
*/