buildtranlist or freetranlist Subroutine

Purpose

Read the advanced accounting records from the advanced accounting data file.

Library

The libaacct.a library.

Syntax

#define <sys/aacct.h>
buildtranlist(filename, trid[], ntrids, begin_time, end_time, tran_list)
char *filename;
unsigned int trid[];
unsigned int ntrids;
long long begin_time;
long long end_time;
struct aacct_tran_rec **tran_list;
freetranlist(tran_list)
struct aacct_tran_rec *tran_list;

Description

The buildtranlist subroutine retrieves the transaction records of the specified transaction type from the accounting data file. The required transaction IDs are passed as arguments, and these IDs are defined in sys/aacct.h. The list of transaction records are returned to the calling program through the tran_list pointer argument.

This API can be called multiple times with different accounting data file names to generate a consolidated list of transaction records from multiple data files. It appends the new file data to the end of the linked list pointed to by the tran_list argument. In addition, it internally sorts the transaction records based on the time of transaction so users can get a time-sorted list of transaction records from this routine. This subroutine can also be used to retrieve the intended transaction records for a particular interval of time by specifying the begin and end times of this interval as arguments.

The freetranlist subroutine frees the memory allocated to these transaction records. It can be used to deallocate memory that has been allocated to the transaction record lists created by routines such as buildtranlist, getproclist, getlparlist, and getarmlist.

Parameters

Item Description
begin_time Specifies the start timestamp for collecting records in a particular intervals. The input is in seconds since EPOCH. Specifying -1 retrieves all the records.
end_time Specifies the end timestamp for collecting records in a particular intervals. The input is in seconds since EPOCH. Specifying -1 retrieves all the records.
filename Name of the advanced accounting data file.
ntrids Count of transaction IDs passed in the array trid.
tran_list Pointer to the linked list of aacct_tran_rec structures that are to be returned to the caller or freed.
trid An array of transaction record type identifiers.

Security

No restrictions. Any user can call this function.

Return Values

Item Description
0 The call to the subroutine was successful.
-1 The call to the subroutine failed.

Error Codes

Item Description
EINVAL The passed pointer is NULL.
ENOENT Specified data file does not exist.
ENOMEM Insufficient memory.
EPERM Permission denied. Unable to read the data file.