JavaScript is required to for searching.
Skip Navigation Links
Exit Print View
Resource Management, Oracle Solaris Zones, and Oracle Solaris 10 Zones Developer's Guide     Oracle Solaris 11.1 Information Library
search filter icon
search icon

Document Information

Preface

1.  Resource Management in the Oracle Solaris Operating System

2.  Projects and Tasks

Overview of Projects and Tasks

/etc/project File

Project and Task API Functions

Code Examples for Accessing project Database Entries

Programming Issues Associated With Projects and Tasks

3.  Using the C Interface to Extended Accounting

4.  Using the Perl Interface to Extended Accounting

5.  Resource Controls

6.  Resource Pools

7.  Design Considerations for Resource Management Applications in Oracle Solaris Zones

8.  Configuration Examples

Index

Code Examples for Accessing project Database Entries

Example 2-1 Printing the First Three Fields of Each Entry in the project Database

The key points for this example include the following:

#include <project.h>

struct project projent;
char buffer[PROJECT_BUFSZ]; /* Use safe buffer size from project.h */
    ...
struct project *pp;

setprojent();  /* Rewind the project database to start at the beginning */

while (1) {
   pp = getprojent(&projent, buffer, PROJECT_BUFSZ);
      if (pp == NULL)
          break;
    printf("%s:%d:%s\n", pp->pj_name, pp->pj_projid, pp->pj_comment);
        ...
};

endprojent();   /* Close the database and free project resources */

Example 2-2 Getting a project Database Entry That Matches the Caller's Project ID

The following example calls getprojbyid() to get a project database entry that matches the caller's project ID. The example then prints the project name and the project ID.

#include <project.h>

struct project *pj;
char buffer[PROJECT_BUFSZ]; /* Use safe buffer size from project.h */

main()
{
   projid_t pjid;
   pjid = getprojid();
   pj = getprojbyid(pjid, &projent, buffer, PROJECT_BUFSZ);
   if (pj == NULL) {
       /* fail; */
   }
   printf("My project (name, id) is (%s, %d)\n", pp->pj_name, pp->pj_projid);
}