|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T f
Length: 1675 (0x68b) Types: TextFile Names: »fullname.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987 └─⟦this⟧ »EUUGD18/General/Cubes/fullname.c«
/* vi:set sw=4 ts=4: */ #ifndef lint static char sccsid[] = "@(#)fullname.c 5.1 (G.M. Paris) 89/01/22"; #endif lint /* ** ** cubes 5.1 Copyright 1989 Gregory M. Paris ** Permission granted to redistribute on a no charge basis. ** All other rights are reserved. ** */ #ifdef GECOS #include <local/gecos.h> #else GECOS #include <pwd.h> #endif GECOS #include <strings.h> #include "cubes.h" /* ** fullname: get full name from password file gecos field XXX Returns a pointer to a static buffer. */ char * fullname(pw) struct passwd *pw; { static char name[NAMELEN]; register int n; #ifdef GECOS /* ** Use the SSD gecos routines to format the name optimally. */ if(ssd_set(pw) != 0) { int mlen; if(strlen(pw->full_name) <= DISPLEN || pw->first_name[0] == '\0') sprintf(name, "%.*s", DISPLEN, pw->full_name); else if((mlen = strlen(pw->last_name)) >= DISPLEN-3) sprintf(name, "%.*s", DISPLEN, pw->last_name); else if(mlen + strlen(pw->first_name) <= DISPLEN-1) sprintf(name, "%s %s", pw->first_name, pw->last_name); else if(pw->middle_name[0] != '\0' && mlen <= DISPLEN-6) sprintf(name, "%.1s. %.1s. %.*s", pw->first_name, pw->middle_name, DISPLEN-6, pw->last_name); else sprintf(name, "%.1s. %.*s", pw->first_name, DISPLEN-3, pw->last_name); ssd_unset(pw); return name; } #endif GECOS /* ** Copy up to comma or DISPLEN characters, whichever is shorter. */ for(n = 0;n < DISPLEN;++n) { if((name[n] = pw->pw_gecos[n]) == ',') break; if(name[n] == '\0') break; } name[n] = '\0'; /* ** No name in gecos, so use login. */ if(name[0] == '\0') sprintf(name, "%.*s", DISPLEN, pw->pw_name); return name; }