Manpages

NAME

project − access project files from Perl

SYNOPSIS

use Sun::Solaris::Project qw(:ALL);

my ($name, $projid, $comment, $users, $groups, $attr) = getprojent();
($name, $projid, $comment, $users, $groups, $attr) = getprojbyname("proj");
my $proj = getdefaultproj("root");

DESCRIPTION

This module provides perl access to the project file library as documented in getprojent(3PROJECT). The interface is similar to the standard perl getxxx() functions such as getpwent() and gethostent(). For detailed descriptions of the individual functions, refer to the getprojent(3PROJECT) and project(4) manual pages.

CONSTANTS
PROJNAME_MAX

maximum length of a project name

FUNCTIONS
getprojent()

Returns the next entry from the projects file. When called in a scalar context, getprojent() returns just the name of the project, or undef when the end of the file is reached. When called in a list context, getprojent() returns a 6-element list consisting of ($name, $projid, $comment, @users, @groups, $attr) . @users and @groups are returned as references to arrays containing the appropriate user or project lists. On end of file, undef is returned.

setprojent()

Rewinds the project database to the beginning of the file.

endprojent()

Closes the project file.

getprojid()

Returns the current numeric project ID.

getprojbyname($name)

Searches the project database for an entry with the specified name, returning undef if it cannot be found or a 6-element list as returned by getprojent() if it can be found.

getprojbyid($id)

Searches the project database for an entry with the specified ID, returning undef if it cannot be found or a 6-element list as returned by getprojent() if it can be found.

getdefaultproj($user)

Returns the default project entry for the specified user in the same format as getprojent(), or undef if the user cannot be found. For full details of the lookup process, see the manual page for getdefaultproj(3PROJECT).

fgetprojent($filehandle)

Returns the next project entry from $filehandle, which is a perl file handle, and must refer to a previously opened file in project(4) format. Return values are the same as for getprojent().

inproj($user, $project)

Checks to see if the specified user is able to use the project. Returns TRUE if the user can use the project and FALSE otherwise.

getprojidbyname($project)

Searches the project database for the specified project and returns the project ID if it is found. If not found, undef is returned.

EXPORTS
By default nothing is exported from this namespace. The following tags can be used to selectively import constants and functions defined in this namespace:

:LIBCALLS

PROJNAME_MAX, getprojent(), setprojent(), endprojent(), getprojbyname(), getprojbyid(), getdefaultproj(), fgetprojent(), inproj(), getprojidbyname(), getprojid()

:ALL

:LIBCALLS

EXAMPLES

Example 1: Get the record for the default project and print its list of attributes.

use Sun::Solaris::Project qw(:ALL);
my ($name, $projid, $comment, $users, $groups, $attr) =
getprojbyname("default");
die("Can’t find default project0) if (! defined($name));
print("Project $name:0);
print("   Project id: $projid0);
print("   Comment:    $comment0);
print("   Users:      @$users0);
print("   Groups:     @$groups0);
print("   Attributes: $attr0);

SEE ALSO

perl(1), getdefaultproj(3PROJECT), getprojent(3PROJECT), project(4)