---
name: "rulexdb_subscribe_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_subscribe_rule"
---

# rulexdb\_subscribe\_rule(3)

store a new rule into the rulex database

## NAME

rulexdb\_subscribe\_rule - store a new rule into the rulex database

## SYNOPSIS

```
#include <rulexdb.h>

int rulexdb_subscribe_rule(RULEXDB *rulexdb, const char *src, int rule_type, unsigned int position);
```

## DESCRIPTION

The **rulexdb\_subscribe\_rule**() function adds a new rule to the specified ruleset in the database referenced by *rulexdb* argument.

The argument *src* points to the text representation of the rule to be added.

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 should be added to the **Classifiers** dataset.

- **RULEXDB\_PREFIX**

  The rule should be added to the **Prefix detectors** ruleset.

- **RULEXDB\_RULE**

  The rule should be treated as a general rule and added to the **General** rules dataset.

- **RULEXDB\_CORRECTOR**

  The rule is a correction rule and should be added to the **Correctors** dataset.

The argument *position* defines position of the newly added rule in the ruleset. If 0, this rule is appended at the end of ruleset, otherwise the new rule will be inserted at the specified position.

## RETURN VALUE

The **rulexdb\_subscribe\_rule**() function returns **RULEXDB\_SUCCESS** which is zero when success or non-zero error code otherwise.

## ERRORS

- **RULEXDB\_FAILURE**

  Referenced database has not been opened, internal data structures are corrupted or some other general failure has occurred.

- **RULEXDB\_EINVKEY**

  The argument *position* has a non-zero value, but it is out of the ruleset range that must be continuous.

- **RULEXDB\_EPARM**

  The argument *rulexdb* or *rule\_type* has an invalid value.

- **RULEXDB\_EACCESS**

  The database is not opened for updating.

## 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\_fetch\_rule**(3)](/rulexdb_fetch_rule/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)

## AUTHOR

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