"Fossies" - the Fresh Open Source Software Archive

Member "rush-1.9/tests/myid.c" (19 Apr 2019, 415 Bytes) of package /linux/privat/rush-1.9.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <unistd.h>
    2 #include <stdio.h>
    3 #include <pwd.h>
    4 #include <grp.h>
    5 #include <assert.h>
    6 
    7 int
    8 main(int argc, char **argv)
    9 {
   10     struct passwd *pw;
   11     struct group *gr;
   12 
   13     pw = getpwuid(getuid());
   14     assert(pw!=NULL);
   15     gr = getgrgid(pw->pw_gid);
   16     assert(gr!=NULL);
   17     printf("%s %lu %s %lu\n",
   18            pw->pw_name,
   19            (unsigned long) pw->pw_uid,
   20            gr->gr_name,
   21            (unsigned long) gr->gr_gid);
   22     return 0;
   23 }