---
name: "genders_testquery"
section: "3"
platform: "linux"
package: "libgenders0-dev"
version: "1.27-3-3.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/genders_testquery"
---

# genders\_testquery(3)

query genders database for a set of nodes

## NAME

genders\_testquery - query genders database for a set of nodes

## SYNOPSIS

**#include \<genders.h\>**

**int genders\_testquery(genders\_t handle, const char \*node, const char \*query);**\

## DESCRIPTION

**genders\_testquery()** tests if the node pointed to by *node* meets the conditions specified in the query.  If *node* is NULL, the current node is tested.  Queries are based on the union, intersection, difference, or complement of genders attributes and values.  The query is passed as a string through the *query* parameter.  The set operation union is represented by two pipe symbols ('\|\|'), intersection by two ampersand symbols ('&&'), difference by two minus symbols ('--'), and complement by a tilde ('~').  Set operations are performed left to right.  Parentheses may be used to change the order of operations.  A list of query examples are listed below.  A NULL query retrieves all nodes from the genders database.\

## EXAMPLES

The following are example queries that can be passed to **genders\_testquery()**.

Test if a node contains the mgmt or login attribute:\
         "mgmt\|\|login"

Test if a node is not a login node:\
         "all--login"

Test if a node is both a login node and ntp server:\
         "login&&ntpserv"

Test if a node is not a mgmt or login node:\
         "~(mgmt\|\|login)"

## RETURN VALUES

If the node as met the conditions of the query, 1 is returned.  0 is returned if the node does not meet the conditions of the query.  On error, -1 is returned, and an error code is returned in *handle*. The error code can be retrieved via [**genders\_errnum**(3)](/genders_errnum/3.md) , and a description of the error code can be retrieved via [**genders\_strerror**(3)](/genders_strerror/3.md). Error codes are defined in genders.h.\

## ERRORS

- **GENDERS\_ERR\_NULLHANDLE**

  The *handle* parameter is NULL.  The genders handle must be created with [**genders\_handle\_create**(3)](/genders_handle_create/3.md).

- **GENDERS\_ERR\_NOTLOADED**

  [**genders\_load\_data**(3)](/genders_load_data/3.md) has not been called to load genders data.

- **GENDERS\_ERR\_PARAMETERS**

  An incorrect parameter has been passed in.

- **GENDERS\_ERR\_SYNTAX**

  There is a syntax error in the query.

- **GENDERS\_ERR\_OUTMEM**

  [**malloc**(3)](/malloc/3.md) has failed internally, system is out of memory.

- **GENDERS\_ERR\_MAGIC**

  *handle* has an incorrect magic number.  *handle* does not point to a genders handle or *handle* has been destroyed by [**genders\_handle\_destroy**(3)](/genders_handle_destroy/3.md).

- **GENDERS\_ERR\_INTERNAL**

  An internal system error has occurred.  \

## FILES

/usr/include/genders.h

## SEE ALSO

[libgenders(3)](/libgenders/3.md), [genders\_handle\_create(3)](/genders_handle_create/3.md), [genders\_load\_data(3)](/genders_load_data/3.md), [genders\_errnum(3)](/genders_errnum/3.md), [genders\_strerror(3)](/genders_strerror/3.md)
