---
name: "cpg_iteration_initialize"
section: "3"
platform: "linux"
package: "libcpg-dev"
version: "3.1.9-2+deb13u1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/cpg_iteration_initialize"
---

# cpg\_iteration\_initialize(3)

Initialize iterator for members of CPG

## NAME

cpg\_iteration\_initialize - Initialize iterator for members of CPG

## SYNOPSIS

**#include \<corosync/cpg.h\>**

**cs\_error\_t** **cpg\_iteration\_initialize (cpg\_handle\_t** *handle***, cpg\_iteration\_type\_t** *iteration\_type***,** **const struct cpg\_name \****group***, cpg\_iteration\_handle\_t \****cpg\_iteration\_handle***);**

## DESCRIPTION

The **cpg\_iteration\_initialize** function is used to initialize iteration of CPG members. The *handle* argument is connection to CPG database obtained by calling **[cpg\_initialize(3)](/cpg_initialize/3.md)** function. *iteration\_type* is used for limit number of returned items and can be one of:

**CPG\_ITERATION\_NAME\_ONLY** - only name of used groups are returned

**CPG\_ITERATION\_ONE\_GROUP** - only members group with name *group* are returned

**CPG\_ITERATION\_ALL** - all members are returned

The *group* parameter is used only with **CPG\_ITERATION\_ONE\_GROUP** and it's name of group with members to iterate. For other *iteration\_type*, this parameter must be NULL.

**cpg\_iteration\_initialize** is used only for initialize context for future **[cpg\_iteration\_next(3)](/cpg_iteration_next/3.md)** calls and handle needed for that function is returned in *cpg\_iteration\_handle* variable. When you have finished iteration over objects, call **[cpg\_iteration\_finalize(3)](/cpg_iteration_finalize/3.md)** function to free up memory associated with iteration.

## RETURN VALUE

This call returns the CS\_OK value if successful. If *cpg\_iteration\_handle* is NULL, **CS\_ERR\_INVALID\_PARAM** error is returned. Same error is returned when *iteration\_type* is **CPG\_ITERATION\_ONE\_GROUP**, but *group* is NULL, or when *group* is not NULL and *iteration\_type* is not **CPG\_ITERATION\_ONE\_GROUP**. If there is not enough memory for internal store of data, **CS\_ERR\_NO\_MEMORY** is returned. **CS\_ERR\_BAD\_HANDLE** can be returned, if *handle* is not valid handle.

## COMMON IPC ERRORS

**CS\_ERR\_TRY\_AGAIN** Resource temporarily unavailable

**CS\_ERR\_INVALID\_PARAM** Invalid argument

**CS\_ERR\_ACCESS** Permission denied

**CS\_ERR\_LIBRARY** The connection failed

**CS\_ERR\_INTERRUPT** System call interrupted by a signal

**CS\_ERR\_NOT\_SUPPORTED** The requested protocol/functionality not supported

**CS\_ERR\_MESSAGE\_ERROR** Incorrect auth message received

**CS\_ERR\_NO\_MEMORY** Not enough memory to complete the requested task

## SEE ALSO

[**cpg\_iteration\_next**(3)](/cpg_iteration_next/3.md), [**cpg\_iteration\_finalize**(3)](/cpg_iteration_finalize/3.md), [**cpg\_initialize**(3)](/cpg_initialize/3.md), [**cpg\_overview**(3)](/cpg_overview/3.md)
