Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgrnam.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgrnam.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgrnam.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgrnam.html on line 8

getgrnam()

Get information about the group with a given name

Synopsis:

#include <sys/types.h>
#include <grp.h>

struct group* getgrnam( const char* name );

Arguments:

name
The name of the group you want to get information about.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The getgrnam() function lets a process gain more knowledge about the group named name. This function uses a static buffer that's overwritten by each call.


Note: The getgrent(), getgrgid(), and getgrnam() functions share the same static buffer.

Returns:

A pointer to an object of type struct group containing an entry from the group database with a matching name, or NULL on error or failure to find an entry with a matching name.

Examples:

/*
 * Print the name of all users in the group given in 
 * argv[1]
 */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <grp.h>

int main( int argc, char** argv )
  {
    struct group* g;
    char** p;

    if( ( g = getgrnam( argv[1] ) ) == NULL ) {
       fprintf( stderr, "getgrnam: %s failed\n",
            argv[1] );
       return( EXIT_FAILURE );
    }
    printf( "group name:%s\n", g->gr_name );
    for( p = g->gr_mem; *p != NULL; p++ ) {
       printf( "\t%s\n", *p );
    }
    return( EXIT_SUCCESS );
  }

Classification:

POSIX 1003.1

Safety:
Cancellation point Yes
Interrupt handler No
Signal handler No
Thread No

See also:

getgrent(), getgrgid(), getgrnam_r()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgrnam.html on line 159

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/g/getgrnam.html on line 159