The above functions and structures are generic but the specific named_interface would also be part of any identifiers. For example, `procps_new' would actually be `procps_meminfo_new' and `info' would really be `diskstats_info', etc.
The same named_interface is used in each header file name with an appended `.h' suffix.
Link with -lproc2.
By specifying an array of `items', these structures can be organized as a `stack', potentially yielding many results with a single function call. Thus, a `stack' can be viewed as a variable length record whose content and order is determined solely by the user.
As part of each interface there are two unique enumerators. The `noop' and `extra' items exist to hold user values. They are never set by the library, but the `extra' result will be zeroed with each library interaction.
The named_interface header file will be an essential document during user program development. There you will find available items, their return type (the `result' struct member name) and the source for such values. Additional enumerators and structures are also documented there.
1. procps_new() 2. procps_get(), procps_select() or procps_reap() 3. procps_unref()
The get function is used to retrieve a `result' structure for a single `item'. Alternatively, a GET macro is available when only the return value is of interest.
The select function can retrieve multiple `result' structures in a single `stack'.
For unpredictable variable outcomes, the diskstats, slabinfo and stat interfaces export a reap function. It is used to retrieve multiple `stacks' each containing multiple `result' structures. Optionally, a user may choose to sort those results.
To exploit any `stack', and access individual `result' structures, a relative_enum is required as shown in the VAL macro defined in the header file. Such values could be hard coded as: 0 through numitems-1. However, this need is typically satisfied by creating your own enumerators corresponding to the order of the `items' array.
For the new and unref functions, the address of an info struct pointer must be supplied. With new it must have been initialized to NULL. With unref it will be reset to NULL if the reference count reaches zero.
In the case of the diskstats interface, a name parameter on the get and select functions identifies a disk or partition name
For the stat interface, a what parameter on the reap function identifies whether data for just CPUs or both CPUs and NUMA nodes is to be gathered.
When using the sort function, the parameters stacks and numstacked would normally be those returned in the `reaped' structure.
Success is indicated by a zero return value. However, the ref and unref functions return the current info structure reference count.
Success is indicated by a pointer to the named structure.
This feature can be activated through either of the following methods and any discrepancies will be written to stderr.
This verification feature incurs substantial overhead. Therefore, it is important that it not be activated for a production/release build.