URI: 
       tgetuser.3 - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       tgetuser.3 (953B)
       ---
            1 .TH GETUSER 3
            2 .SH NAME
            3 getuser, sysname \- get user or system name
            4 .SH SYNOPSIS
            5 .B #include <u.h>
            6 .br
            7 .B #include <libc.h>
            8 .PP
            9 .B
           10 char*        getuser(void)
           11 .PP
           12 .B
           13 char*        sysname(void)
           14 .SH DESCRIPTION
           15 .I Getuser
           16 returns a pointer to static data which contains the
           17 null-terminated
           18 name of the user who
           19 owns the current process.
           20 .I Getuser
           21 calls
           22 .MR getuid (2)
           23 and then reads
           24 .B /etc/passwd
           25 to find the corresponding name.
           26 .PP
           27 .I Sysname
           28 returns a pointer to static data which contains the name
           29 of the machine on which the current process is running.
           30 .I Sysname
           31 looks first for an environment variable
           32 .BR $sysname .
           33 If there is no such variable,
           34 .I sysname
           35 calls
           36 .MR gethostname (2)
           37 and truncates the returned name at the first dot.
           38 If
           39 .I gethostname 
           40 fails,
           41 .I sysname
           42 returns the default name
           43 .LR gnot .
           44 .PP
           45 Unlike
           46 .IR getuser ,
           47 .I sysname
           48 caches the string, deriving the host name only once.
           49 .SH SOURCE
           50 .B \*9/src/lib9/getuser.c
           51 .br
           52 .B \*9/src/lib9/sysname.c