Date: Mon, 21 Oct 2002 09:43:36 -0700 (PDT) From: Brian Feldman <green@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 19798 for review Message-ID: <200210211643.g9LGhaXA010372@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=19798 Change 19798 by green@green_laptop_2 on 2002/10/21 09:42:38 Correct printing of MAC labels to justify/align properly. Affected files ... .. //depot/projects/trustedbsd/mac/bin/ps/extern.h#10 edit .. //depot/projects/trustedbsd/mac/bin/ps/keyword.c#12 edit .. //depot/projects/trustedbsd/mac/bin/ps/print.c#14 edit Differences ... ==== //depot/projects/trustedbsd/mac/bin/ps/extern.h#10 (text+ko) ==== @@ -71,6 +71,7 @@ void rgroupname(KINFO *, VARENT *); void runame(KINFO *, VARENT *); void rvar(KINFO *, VARENT *); +int s_label(KINFO *); int s_rgroupname(KINFO *); int s_runame(KINFO *); int s_uname(KINFO *); ==== //depot/projects/trustedbsd/mac/bin/ps/keyword.c#12 (text+ko) ==== @@ -95,7 +95,8 @@ 0}, {"ktrace", "KTRACE", NULL, 0, kvar, NULL, 8, KOFF(ki_traceflag), INT, "x", 0}, - {"label", "LABEL", NULL, LJUST, label, NULL, 0, 0, CHAR, NULL, 0}, + {"label", "LABEL", NULL, LJUST|DSIZ, label, s_label, SHRT_MAX, 0, CHAR, + NULL, 0}, {"lim", "LIM", NULL, 0, maxrss, NULL, 5, 0, CHAR, NULL, 0}, {"login", "LOGIN", NULL, LJUST, logname, NULL, MAXLOGNAME-1, 0, CHAR, NULL, 0}, ==== //depot/projects/trustedbsd/mac/bin/ps/print.c#14 (text+ko) ==== @@ -749,9 +749,34 @@ mac_free(label); out: - if (string != NULL) - (void)printf("%*s", v->width, string); - else - (void)printf("%*s", v->width, ""); + if (string != NULL) { + (void)printf("%-*s", v->width, string); + free(string); + } else + (void)printf("%-*s", v->width, ""); return; } + +int +s_label(KINFO *k) +{ + char *string = NULL; + mac_t label; + int error, size = 0; + + if (mac_prepare_process_label(&label) == -1) { + perror("mac_prepare_process_label"); + fprintf(stderr, "returning size %d for pid %d\n", 0, + k->ki_p->ki_pid); + return (0); + } + error = mac_get_pid(k->ki_p->ki_pid, label); + if (error == 0 && mac_to_text(label, &string) == 0) { + size = strlen(string); + free(string); + fprintf(stderr, "returning size %d for pid %d\n", size, + k->ki_p->ki_pid); + } + mac_free(label); + return (size); +} To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe p4-projects" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210211643.g9LGhaXA010372>