addprojdb Subroutine

Purpose

Adds a project definition to the specified project database.

Library

The libaacct.a library.

Syntax

<sys/aacct.h>

addprojdb(void *handle, struct project *project, char *comment)

Description

The addprojdb subroutine appends the project definition stored in the struct project variable into the project database named by the handle parameter. The project database must be initialized before calling this subroutine. The projdballoc subroutine is provided for this purpose. This routine verifies whether the supplied project definition already exists. If it does exist, the addprojdb subroutine sets errno to EEXIST and returns -1.

The addprojdb subroutine validates the input project number to ensure that it is within the expected range 0x00000001 - 0x00ffffff and validates that the project name is a POSIX-compliant alphanumeric character string. If any invalid input is found, the addprojdb subroutine sets errno to EINVAL and returns -1.

If the user does not have privilege to add an entry to project database, the addprojdb subroutine sets errno to EACCES and returns -1.

There is an internal state (that is, the current project) associated with the project database. When the project database is initialized, the current project is the first project in the database. The addprojdb subroutine appends the specified project to the end of the database. It advances the current project assignment to the next project in the database, which is the end of the project data base. At this point, a call to the getnextprojdb subroutine would fail, because there are no additional project definitions. To read the project definition that was just added, use the getprojdb subroutine. To read other projects, first call getfirstprojdb subroutine to reset the internal current project assignment so that subsequent reads can be performed.

The format of the records added to the project database are given as follows:
ProjectName:ProjectNumber:AggregationStatus:Comment::
Example:
Biology:4756:no:Project Created by projctl command::

Parameters

Item Description
handle Pointer to project database handle
project Pointer to a project structure that holds the definition of the project to be added
comment Pointer to a character string that holds the comments about the project

Security

Only for privileged users. Privilege can be extended to nonroot users by granting the CAP_AACCT capability to a user.

Return Values

Item Description
0 Success
-1 Failure

Error Codes

Item Description
EINVAL Invalid project name or number, or the passed pointer is NULL.
EEXIST Project definition already exists.
EPERM Permission denied. The user is not a privileged user.