# &develguide;

The module exports a number of parameters and functions that are used in several other modules.

## `bind_xcap_api(xcap_api_t* api)`

This function allows binding the needed functions.

### `xcap_api` structure

    ...
    typedef struct xcap_api {
            int integrated_server;
            str db_url;
            str xcap_table;
            normalize_sip_uri_t normalize_sip_uri;
            parse_xcap_uri_t parse_xcap_uri;
            get_xcap_doc_t get_xcap_doc;
    } xcap_api_t;
    ...

## `normalize_xcap_uri`

This function normalizes a SIP URI found in a XCAP document. It un-escapes it and adds the SIP scheme in case it was missing. Returns a statically allocated string buffer containing the normalized form.

Parameters:

- uri- the URI that needs to be normalized

## `parse_xcap_uri`

This function parses the given XCAP URI.

Parameters:

- uri- the URI that needs to be parsed in string format

- xcap_uri- xcap_uri_t structure that will be filled with the parsed information

      Parameter type:
      ...
      typedef struct {
          char buf[MAX_URI_SIZE];
          str uri;
          str root;
          str auid;
          str tree;
          str xui;
          str filename;
          str selector;
      } xcap_uri_t;
      ...

## `get_xcap_doc`

This function queries the local DB for the required XCAP document. It will return the document and its corresponding etag.

Parameters:

- user- user part od the URI of the document owner

- domain- domain part od the URI of the document owner

- type- type of the requested document, represents the AUID, can be one of PRES_RULES, RESOURCE_LISTS, RLS_SERVICES, PIDF_MANIPULATION, OMA_PRES_RULES

- filename- if specified it will be used to match the document filename, it defaults to 'index'

- match_etag- if specified the document is only returned its etag matches this one

- doc- reference to the storage for the returned document

- etag- reference to the storage for the returned document's etag

## `db_url`

URL of the database to which the XCAP mdoules witll connect.

## `xcap_table`

Name of the table used to store XCAP documents. Defaults to 'xcap'.

## `integrated_server`

Boolean flag indicating if the XCAP server has access to the local database or xcap_client will be used to fetch documents.