apps/top.c
/**
 * @brief Given a UID, get the username.
 *
 * Always returns a string that must be freed. If the uid
 * could not be found in the passwd database, the uid itself
 * is formatted as a string for display.
 */
@brief Given a UID, get the username.
Always returns a string that must be freed. If the uid
could not be found in the passwd database, the uid itself
is formatted as a string for display.
@brief Given a UID get the username . Always returns a string that must be freed . If the uid could not be found in the passwd database the uid itself is formatted as a string for display .
char * format_username(int uid) {
	static char tmp[100];
	struct passwd * p = getpwuid(uid);
	if (p) {
		snprintf(tmp, 100, "%-8s", p->pw_name);
	} else {
		snprintf(tmp, 100, "%-8d", uid);
	}
	endpwent();
	return strdup(tmp);
}
char * format_username ( int uid ) { static char tmp [ 100 ] ; struct passwd * p = getpwuid ( uid ) ; if ( p ) { snprintf ( tmp , 100 , " " , p -> pw_name ) ; } else { snprintf ( tmp , 100 , " " , uid ) ; } endpwent ( ) ; return strdup ( tmp ) ; }
@brief Given a UID, get the username.
@brief Given a UID get the username .