---
name: "rulexdb_fetch_rule"
section: "3"
platform: "linux"
package: "librulexdb-dev"
version: "3.8.6-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/rulexdb_fetch_rule"
---

# rulexdb\_fetch\_rule(3)

extract specified rule from the rulex database

## NAME

rulexdb\_fetch\_rule - extract specified rule from the rulex database

## SYNOPSIS

```
#include <rulexdb.h>

char *rulexdb_fetch_rule(RULEXDB *rulexdb, int rule_type, int position);
```

## DESCRIPTION

The **rulexdb\_fetch\_rule**() function retrieves a rule identified by its type and position in the ruleset from the rulex database referenced by *rulexdb* argument.

The argument *rule\_type* specifies the rule type. It may accept one of the following values:

- **RULEXDB\_LEXCLASS**

  The rule is the word classifier and belongs to the **Classifiers** dataset.

- **RULEXDB\_PREFIX**

  The rule describes prefix detection and replacement and belongs to the\
    **Prefix detectors** ruleset.

- **RULEXDB\_RULE**

  The requested rule should be extracted from the **General** rules dataset.

- **RULEXDB\_CORRECTOR**

  The rule is a correction rule that belongs to the **Correctors** dataset.

The argument *position* defines position of the requested rule in the ruleset.

## RETURN VALUE

Upon success, the **rulexdb\_fetch\_rule**() function returns pointer to the textual representation of the extracted rule. This pointer remains valid until the next database operation. Otherwise, NULL is returned.

## SEE ALSO

[**rulexdb\_classify**(3)](/rulexdb_classify/3.md), [**rulexdb\_close**(3)](/rulexdb_close/3.md), [**rulexdb\_dataset\_name**(3)](/rulexdb_dataset_name/3.md), [**rulexdb\_discard\_dictionary**(3)](/rulexdb_discard_dictionary/3.md), [**rulexdb\_discard\_ruleset**(3)](/rulexdb_discard_ruleset/3.md), [**rulexdb\_lexbase**(3)](/rulexdb_lexbase/3.md), [**rulexdb\_load\_ruleset**(3)](/rulexdb_load_ruleset/3.md), [**rulexdb\_open**(3)](/rulexdb_open/3.md), [**rulexdb\_remove\_item**(3)](/rulexdb_remove_item/3.md), [**rulexdb\_remove\_rule**(3)](/rulexdb_remove_rule/3.md), [**rulexdb\_remove\_this\_item**(3)](/rulexdb_remove_this_item/3.md), [**rulexdb\_retrieve\_item**(3)](/rulexdb_retrieve_item/3.md), [**rulexdb\_search**(3)](/rulexdb_search/3.md), [**rulexdb\_seq**(3)](/rulexdb_seq/3.md), [**rulexdb\_subscribe\_item**(3)](/rulexdb_subscribe_item/3.md), [**rulexdb\_subscribe\_rule**(3)](/rulexdb_subscribe_rule/3.md)

## AUTHOR

Igor B. Poretsky \<poretsky@mlbox.ru\>.
