Annotation of researchv10no/lbin/mailx/getname.c, revision 1.1

1.1     ! root        1: #ident "@(#)getname.c  1.4 'attmail mail(1) command'"
        !             2: #ident "@(#)mailx:getname.c    1.3.1.1"
        !             3: /*     Copyright (c) 1984 AT&T */
        !             4: /*       All Rights Reserved   */
        !             5: 
        !             6: /*     THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T     */
        !             7: /*     The copyright notice above does not evidence any        */
        !             8: /*     actual or intended publication of such source code.     */
        !             9: 
        !            10: /*
        !            11:  * mailx -- a modified version of a University of California at Berkeley
        !            12:  *     mail program
        !            13:  */
        !            14: 
        !            15: #include "rcv.h"
        !            16: #include <pwd.h>
        !            17: #ifdef preSVr4
        !            18: extern struct passwd *getpwnam();
        !            19: extern struct passwd *getpwuid();
        !            20: #endif
        !            21: 
        !            22: /*
        !            23:  * Search the passwd file for a uid.  Return name through ref parameter
        !            24:  * if found, indicating success with 0 return.  Return -1 on error.
        !            25:  * If -1 is passed as the user id, close the passwd file.
        !            26:  */
        !            27: 
        !            28: getname(uid, namebuf)
        !            29:        uid_t uid;
        !            30:        char namebuf[];
        !            31: {
        !            32:        struct passwd *pw;
        !            33: 
        !            34:        if (uid == (uid_t)-1) {
        !            35:                endpwent();
        !            36:                return(0);
        !            37:        }
        !            38:        setpwent();
        !            39:        pw = getpwuid(uid);
        !            40:        if (pw) {
        !            41:                strcpy(namebuf, pw->pw_name);
        !            42:                return(0);
        !            43:        }
        !            44:        return(-1);
        !            45: }
        !            46: 
        !            47: /*
        !            48:  * Convert the passed name to a user id and return it.  Return -1
        !            49:  * on error.  Iff the name passed is 0, close the passwd file.
        !            50:  */
        !            51: 
        !            52: uid_t
        !            53: getuserid(name)
        !            54:        char name[];
        !            55: {
        !            56:        struct passwd *pw;
        !            57: 
        !            58:        if (name == 0) {
        !            59:                endpwent();
        !            60:                return(0);
        !            61:        }
        !            62:        setpwent();
        !            63:        pw = getpwnam(name);
        !            64:        return pw ? pw->pw_uid : (uid_t)-1;
        !            65: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.