Strategies
==========

     struct dico_strategy {
         char *name;
         char *descr;
         dico_select_t sel;
         void *closure;
         int is_default;
     };

 -- Function: dico_strategy_t dico_strategy_dup (const dico_strategy_t
     STRAT)

 -- Function: dico_strategy_t dico_strategy_find (const char *NAME)

 -- Function: int dico_strategy_add (const dico_strategy_t STRAT)

 -- Function: dico_iterator_t dico_strategy_iterator (void)

 -- Function: void dico_strategy_iterate (dico_list_iterator_t
     ITR, void *DATA)

 -- Function: size_t dico_strategy_count (void)

 -- Function: int dico_set_default_strategy (const char *NAME)

 -- Function: const dico_strategy_t dico_get_default_strategy (void)

 -- Function: int dico_strategy_is_default_p (dico_strategy_t STRAT)

argcv
=====

 -- enum: dico_argcv_quoting_style

 -- Variable: enum dico_argcv_quoting_style dico_argcv_quoting_style

 -- Function: int dico_argcv_get (const char *COMMAND,
     const char *DELIM, const char *CMNT,
     int *ARGC, char ***ARGV)
 -- Function: int dico_argcv_get_n (const char *COMMAND,
     int LEN,
     const char *DELIM, const char *CMNT,
     int *ARGC, char ***ARGV)
 -- Function: int dico_argcv_get_np (const char *COMMAND,
     int LEN,
     const char *DELIM, const char *CMNT,
     int FLAGS,
     int *ARGC, char ***ARGV, char **ENDP)

 -- Function: int dico_argcv_string (int ARGC,
     const char **ARGV, char **STRING)

 -- Function: void dico_argcv_free (int ARGC, char **ARGV)

 -- Function: void dico_argv_free (char **ARGV)

 -- Function: int dico_argcv_unquote_char (int C)

 -- Function: int dico_argcv_quote_char (int C)

 -- Function: size_t dico_argcv_quoted_length (const char *STR,
     int *QUOTE)

 -- Function: void dico_argcv_unquote_copy (char *DST,
     const char *SRC, size_t N)

 -- Function: void dico_argcv_quote_copy (char *DST,
     const char *SRC)

 -- Function: void dico_argcv_remove (int *ARGC,
     char ***ARGV,
     int (*SEL) (const char *, void *), void *DATA)

Lists
=====

 -- Type: dico_list_t

 -- Type: dico_iterator_t

 -- Function Type: dico_list_iterator_t

          typedef int (*dico_list_iterator_t)(void *item, void *data);

 -- Function Type: dico_list_comp_t

          typedef int (*dico_list_comp_t)(const void *, const void *);

 -- Function: dico_list_t dico_list_create (void)

 -- Function: void dico_list_destroy (dico_list_t *LIST,
     dico_list_iterator_t FREE, void *DATA)

 -- Function: void dico_list_iterate (dico_list_t LIST,
     dico_list_iterator_t ITR, void *DATA)

 -- Function: void * dico_list_item (dico_list_t LIST,
     size_t N)

 -- Function: size_t dico_list_count (dico_list_t LIST)

 -- Function: int dico_list_append (dico_list_t LIST, void *DATA)

 -- Function: int dico_list_prepend (dico_list_t LIST, void *DATA)
 -- Function: int dico_list_push (dico_list_t LIST, void *DATA)

 -- Function: int dico_list_insert_sorted (dico_list_t LIST,
     void *DATA, dico_list_comp_t CMP)

 -- Function: dico_list_t dico_list_intersect (dico_list_t A,
     dico_list_t B, dico_list_comp_t CMP)

 -- Function: int dico_list_intersect_p (dico_list_t A,
     dico_list_t B, dico_list_comp_t CMP)

 -- Function: void * dico_list_pop (dico_list_t LIST)

 -- Function: void * dico_list_locate (dico_list_t LIST,
     void *DATA, dico_list_comp_t CMP)

 -- Function: void * dico_list_remove (dico_list_t LIST,
     void *DATA, dico_list_comp_t CMP)

 -- Function: void * dico_iterator_current (dico_iterator_t ITR)

 -- Function: dico_iterator_t dico_iterator_create (dico_list_t LIST)

 -- Function: void dico_iterator_destroy (dico_iterator_t *PITR)

 -- Function: void * dico_iterator_first (dico_iterator_t ITR)

 -- Function: void * dico_iterator_next (dico_iterator_t ITR)

 -- Function: void * dico_iterator_remove_current (dico_iterator_t ITR)

 -- Function: void dico_iterator_set_data (dico_iterator_t ITR,
     void *DATA)

Associative lists
=================

     struct dico_assoc {
         char *key;
         char *value;
     };

 -- Type: dico_assoc_list_t

 -- Function: dico_assoc_list_t dico_assoc_create (void)

 -- Function: dico_assoc_list_t dico_assoc_dup(dico_assoc_list_t SRC)

 -- Function: void dico_assoc_destroy (dico_assoc_list_t *PASSOC)

 -- int: dico_assoc_clear(dico_assoc_list_t ASSOC)

 -- Function: int dico_assoc_add (dico_assoc_list_t ASSOC,
     const char *KEY, const char *VALUE)

 -- Function: int dico_assoc_append(dico_assoc_list_t ASSOC,
     const char *KEY, const char *VALUE)

 -- Function: const char *dico_assoc_find_n(
     dico_assoc_list_t ASSOC,
     const char *KEY, size_t N)

 -- Function: const char * dico_assoc_find (
     dico_assoc_list_t ASSOC,  const char *KEY)

 -- Function: void dico_assoc_remove_n(
     dico_assoc_list_t ASSOC, const char *KEY, size_t N)

 -- Function: void dico_assoc_remove (
     dico_assoc_list_t ASSOC, const char *KEY)

 -- Function: size_t dico_assoc_count(dico_assoc_list_t ASSOC)

 -- Function: dico_iterator_t dico_assoc_iterator(
     dico_assoc_list_t ASSOC)

Diagnostics Functions
=====================

L_DEBUG

L_INFO

L_NOTICE

L_WARN

L_ERR

L_CRIT

L_ALERT

L_EMERG

 -- Variable: const char * dico_program_name

 -- Variable: const char * dico_invocation_name

 -- Function: void dico_set_program_name (char *NAME)

 -- Function Type: void dico_log_printer_t (
     int LVL, int EXITCODE, int ERRCODE,
     const char *FMT,
     va_list AP)

 -- Function: void dico_set_log_printer (dico_log_printer_t PRT)

 -- Function: void dico_vlog (
     int LVL, int ERRCODE, const char *FMT, va_list AP)

 -- Function: void dico_log (int LVL, int ERRCODE,
     const char *FMT, ...)

 -- Function: void dico_die (int EXITCODE, int LVL,
     int ERRCODE, char *FMT, ...)

 -- Function: int dico_str_to_diag_level (const char *STR)

 -- Function: dico_stream_t dico_log_stream_create (int LEVEL)

Filter
======

 -- Define: FILTER_ENCODE

 -- Define: FILTER_DECODE

 -- Function Type: filter_xcode_t

          typedef int (*filter_xcode_t) (const char *, size_t,
                                         char *, size_t, size_t *, size_t, size_t *);

 -- Function: dico_stream_t filter_stream_create (
     dico_stream_t STR,
     size_t MIN_LEVEL,
     size_t MAX_LINE_LENGTH,
     filter_xcode_t XCODE,
     int MODE)

 -- Function: dico_stream_t dico_codec_stream_create (
     const char *ENCODING, int MODE, dico_stream_t
     TRANSPORT)

 -- Function: dico_stream_t dico_base64_stream_create (
     dico_stream_t STR, int MODE)

 -- Function: dico_stream_t dico_qp_stream_create (
     dico_stream_t STR, int MODE)

 -- Function: int dico_base64_input (char C)

 -- Function: int dico_base64_decode (
     const char *IPTR, size_t ISIZE,
     char *OPTR, size_t OSIZE,
     size_t *PNBYTES,
     size_t LINE_MAX, size_t *PLINE_LEN)

 -- Function: int dico_base64_encode (
     const char *IPTR, size_t ISIZE,
     char *OPTR, size_t OSIZE,
     size_t *PNBYTES, size_t LINE_MAX,
     size_t *PLINE_LEN)

 -- Function: int dico_qp_decode (
     const char *IPTR, size_t ISIZE,
     char *OPTR, size_t OSIZE,
     size_t *PNBYTES,
     size_t LINE_MAX, size_t *PLINE_LEN)

 -- Function: int dico_qp_encode (
     const char *IPTR, size_t ISIZE,
     char *OPTR, size_t OSIZE,
     size_t *PNBYTES,
     size_t LINE_MAX, size_t *PLINE_LEN)

parseopt
========

DICO_PARSEOPT_PARSE_ARGV0

DICO_PARSEOPT_PERMUTE

 -- Enumeration: dico_opt_type

     dico_opt_null

     dico_opt_bool

     dico_opt_bitmask

     dico_opt_bitmask_rev

     dico_opt_long

     dico_opt_string

     dico_opt_enum

     dico_opt_const

     dico_opt_const_string

 -- struct: dico_option

          struct dico_option {
              const char *name;
              size_t len;
              enum dico_opt_type type;
              void *data;
              union {
                  long value;
                  const char **enumstr;
              } v;
              int (*func) (struct dico_option *, const char *);
          };

 -- Macro: DICO_OPTSTR name

 -- Function: int dico_parseopt (struct dico_option *OPT,
     int ARGC, char **ARGV, int FLAGS, int *INDEX)

stream
======

 -- Function: int dico_stream_create (dico_stream_t *PSTREAM,
     int FLAGS, void *DATA)

     DICO_STREAM_READ

     DICO_STREAM_WRITE

     DICO_STREAM_SEEK

 -- Function: int dico_stream_open (dico_stream_t STREAM)

 -- Function: void dico_stream_set_open (
     dico_stream_t STREAM, int (*OPENFN) (void *, int))

 -- Function: void dico_stream_set_seek (
     dico_stream_t STREAM,
     int (*FUN_SEEK) (void *, off_t, int, off_t *))

 -- Function: void dico_stream_set_size (
     dico_stream_t STREAM, int (*SIZEFN) (void *, off_t *))

 -- Function: void dico_stream_set_read (
     dico_stream_t STREAM,
     int (*READFN) (void *, char *, size_t, size_t *))

 -- Function: void dico_stream_set_write (
     dico_stream_t STREAM,
     int (*WRITEFN) (void *, const char *, size_t, size_t *))

 -- Function: void dico_stream_set_flush (
     dico_stream_t STREAM, int (*FLUSHFN) (void *))

 -- Function: void dico_stream_set_close (
     dico_stream_t STREAM, int (*CLOSEFN) (void *))

 -- Function: void dico_stream_set_destroy (
     dico_stream_t STREAM, int (*DESTROYFN) (void *))

 -- Function: void dico_stream_set_ioctl (
     dico_stream_t STREAM, int (*CTL) (void *, int, void *))

 -- Function: void dico_stream_set_error_string (
     dico_stream_t STREAM,
     const char *(*ERROR_STRING) (void *, int))

 -- Function: int dico_stream_set_buffer (
     dico_stream_t STREAM,
     enum dico_buffer_type TYPE,
     size_t size)

      -- Enumeration: dico_buffer_type

          dico_buffer_none

          dico_buffer_line

          dico_buffer_full

 -- Function: off_t dico_stream_seek (
     dico_stream_t STREAM, off_t OFFSET, int WHENCE)

     DICO_SEEK_SET

     DICO_SEEK_CUR

     DICO_SEEK_END

 -- Function: int dico_stream_size (dico_stream_t STREAM,
     off_t *PSIZE)

 -- Function: int dico_stream_read_unbuffered (
     dico_stream_t STREAM,
     void *BUF, size_t SIZE,
     size_t *PREAD)

 -- Function: int dico_stream_write_unbuffered (
     dico_stream_t STREAM,
     const void *BUF, size_t SIZE,
     size_t *PWRITE)

 -- Function: int dico_stream_read (
     dico_stream_t STREAM,
     void *BUF, size_t SIZE,
     size_t *PREAD)

 -- Function: int dico_stream_readln (
     dico_stream_t STREAM,
     char *BUF, size_t SIZE,
     size_t *PREAD)

 -- Function: int dico_stream_getdelim (
     dico_stream_t STREAM,
     char **PBUF, size_t *PSIZE,
     int DELIM, size_t *PREAD)

 -- Function: int dico_stream_getline (
     dico_stream_t STREAM,
     char **PBUF, size_t *PSIZE,
     size_t *PREAD)

 -- Function: int dico_stream_write (
     dico_stream_t STREAM, const void *BUF, size_t SIZE)

 -- Function: int dico_stream_writeln (
     dico_stream_t STREAM, const char *BUF, size_t SIZE)

 -- Function: int dico_stream_ioctl (
     dico_stream_t STREAM, int CODE, void *PTR)

 -- Function: const char * dico_stream_strerror (
     dico_stream_t STREAM, int RC)

 -- Function: int dico_stream_last_error (dico_stream_t STREAM)

 -- Function: void dico_stream_clearerr (dico_stream_t STREAM)

 -- Function: int dico_stream_eof (dico_stream_t STREAM)

 -- Function: int dico_stream_flush (dico_stream_t STREAM)

 -- Function: int dico_stream_close (dico_stream_t STREAM)

 -- Function: void dico_stream_destroy (dico_stream_t *STREAM)

 -- Function: off_t dico_stream_bytes_in (dico_stream_t STREAM)

 -- Function: off_t dico_stream_bytes_out (dico_stream_t STREAM)

url
===

 -- struct: dico_url

          #define DICO_REQUEST_DEFINE 0
          #define DICO_REQUEST_MATCH 1

          struct dico_request {
              int type;
              char *word;
              char *database;
              char *strategy;
              unsigned long n;
          };

          struct dico_url {
              char *string;
              char *proto;
              char *host;
              int port;
              char *path;
              char *user;
              char *passwd;
              dico_assoc_list_t args;
              struct dico_request req;
          };

 -- Pointer: dico_url_t

 -- Function: int dico_url_parse (dico_url_t *PURL,
     const char *STR)

 -- Function: void dico_url_destroy (dico_url_t *PURL)

 -- Function: const char * dico_url_get_arg (
     dico_url_t URL, const char *ARGNAME)

 -- Function: char * dico_url_full_path (dico_url_t URL)

UTF-8
=====

This section describes functions for handling UTF-8 strings.  A UTF-8 character can be represented either as a multi-byte character or a wide character.

Multibyte character is a char * pointing to one or more bytes representing the UTF-8 character.

Wide character is an unsigned value identifying the character.

In the discussion below, a sequence of one or more multi-byte characters is called a multi-byte string.  Multibyte strings terminate with a single nul (0) character.

A sequence of one or more wide characters is called a wide character string.  Such strings terminate with a single 0 value.

Character sizes
---------------

 -- Function: size_t utf8_char_width (const unsigned char *CP)
     Returns length in bytes of the UTF-8 character representation pointed to by CP.

 -- Function: size_t utf8_strlen (const char *STR)
     Returns number of UTF-8 characters (not bytes) in STR.

 -- Function: size_t utf8_wc_strlen (const unsigned *S)
     Returns number of wide characters in the wide character string S.

Iterating over UTF-8 strings
----------------------------

 -- struct: utf8_iterator
     A data type for iterating over a string of UTF-8 characters.  Defined as:

          struct utf8_iterator {
              char *string;
              char *curptr;
              unsigned curwidth;
          };

     When iterating over characters in string, curptr points to the current character, and curwidth holds its length in bytes.

 -- Function: int utf8_iter_isascii (struct utf8_iterator ITR)
     Returns true if ITR points to a ASCII character.

 -- Function: int utf8_iter_end_p (struct utf8_iterator *ITR)
     Returns true if ITR reached end of the input string.

 -- Function: int utf8_iter_first (struct utf8_iterator *ITR,
     unsigned char *STR)
     Initializes ITR for iterating over the string STR. On success, positions ITR.curptr to the next character from the input string, sets ITR.curwidth to the length of that character in bytes, and returns 0.  If STR is an empty string, returns 1.

 -- Function: int utf8_iter_next (struct utf8_iterator *ITR)
     Positions ITR.curptr to the next character from the input string.  Sets ITR.curwidth to the length of that character in bytes.

Conversions
-----------

The following functions convert between the two string representations.

 -- Function: int utf8_mbtowc_internal (void *DATA,
     int (*READ) (void*), unsigned int *PWC)
     Internal function for converting a single UTF-8 character to a corresponding wide character representation.  The character to convert is obtained by calling the function pointed to by READ with DATA as its only argument.  If that call returns a non-positive value, the function sets errno to ENODATA and returns -1.

 -- Function: int utf8_mbtowc (unsigned int *PWC,
     const char *R, size_t LEN)
     Converts first LEN characters from the multi-byte string R to wide character representation.  On success, returns 0 and stores the result in PWC.  The result pointer is allocated using malloc(3).

     On error (invalid multi-byte sequence encountered), returns -1 and sets errno to EILSEQ.

 -- Function: int utf8_wctomb (unsigned char *R,
     unsigned int WC)
     Stores the UTF-8 representation of the Unicode character wc in r[0..5]. Returns the number of bytes stored.  If WC is out of range, return -1 and sets errno to EILSEQ.

 -- Function: int utf8_wc_to_mbstr (const unsigned *WORD,
     size_t WORDLEN, char **RETPTR)
     Converts first WORDLEN characters of the wide character string WORD to multi-byte representation.  The result is returned in RETPTR.  It is allocated using malloc(3).

     Returns 0 on success.  On error, returns -1 and sets errno to one of the following values:

     ENOMEM
          Not enough memory to allocate the return buffer.

     EILSEQ
          An invalid wide character is encountered.

 -- Function: int utf8_mbstr_to_wc (const char *STR,
     unsigned **WPTR, size_t *PLEN)
     Converts a multi-byte string from STR to its wide character representation.

     The result is returned in RETPTR.  It is allocated using malloc(3).

     Returns 0 on success.  On error, returns -1 and sets errno to one of the following values:

     ENOMEM
          Not enough memory to allocate the return buffer.

     EILSEQ
          An invalid wide character is encountered.

 -- Function: int utf8_mbstr_to_norm_wc (const char *STR,
     unsigned **WPTR, size_t *PLEN)
     Converts a multi-byte string from STR to its wide character representation, replacing each run of one or more whitespace characters with a single space character (ASCII 32).

     The result is returned in RETPTR.  It is allocated using malloc(3).

     Returns 0 on success.  On error, returns -1 and sets errno to one of the following values:

     ENOMEM
          Not enough memory to allocate the return buffer.

     EILSEQ
          An invalid wide character is encountered.

Comparing UTF-8 strings
-----------------------

 -- Function: int utf8_symcmp (unsigned char *A,
     unsigned char *B)
     Compares first UTF-8 characters from A and B.

 -- Function: int utf8_symcasecmp (unsigned char *A,
     unsigned char *B)
     Compares first UTF-8 characters from A and B, ignoring the case.

 -- Function: int utf8_strcasecmp (unsigned char *A,
     unsigned char *B)
     Compares the two UTF-8 strings A and B, ignoring the case of the characters.

 -- Function: int utf8_strncasecmp (unsigned char *A,
     unsigned char *B, size_t MAXLEN)
     Compares at most MAXLEN first characters from the two UTF-8 strings A and B, ignoring the case of the characters.

 -- Function: int utf8_wc_strcmp (const unsigned *A,
     const unsigned *B)
     Compare the two wide character strings A and B.

 -- Function: int utf8_wc_strncmp (const unsigned *A,
     const unsigned *B, size_t N)
     Compares at most N first characters from the wide character strings A and B.

 -- Function: int utf8_wc_strcasecmp (const unsigned *A, const unsigned *B)
     Compares the two wide character strings A and B, ignoring the case of the characters.

 -- Function: int utf8_wc_strncasecmp (const unsigned *A,
     const unsigned *B, size_t N)
     Compares at most first N characters of the two wide character strings A and B, ignoring the case.

Character lookups
-----------------

 -- Function: unsigned * utf8_wc_strchr (const unsigned *STR,
     unsigned CHR)
     Returns a pointer to the first occurrence of wide character CHR in string STR, or NULL, if no such character is encountered.

 -- Function: unsigned * utf8_wc_strchr_ci (const unsigned *STR,
     unsigned CHR)
     Returns a pointer to the first occurrence of wide character CHR (case-insensitive) in string STR, or NULL, if no such character is encountered.

 -- Function: const unsigned * utf8_wc_strstr (const unsigned *vartext,
     const unsigned *PATTERN)
     Finds the first occurrence of PATTERN in TEXT.  Returns a pointer to the beginning of pattern in TEXT.  Returns NULL if no occurrence was found.

Functions for converting UTF-8 characters
-----------------------------------------

 -- Function: unsigned utf8_wc_toupper (unsigned WC)
     Converts wide character WC to upper case, if possible.  Returns WC, if it cannot be converted.

 -- Function: int utf8_toupper (char *S, size_t LEN)
     Converts first LEN bytes of the UTF-8 string S to upper case, if possible.

 -- Function: unsigned utf8_wc_tolower (unsigned WC)
     Converts wide character WC to lower case, if possible.  Returns WC, if it cannot be converted.

 -- Function: int utf8_tolower (char *S, size_t LEN)
     Converts first LEN bytes of the UTF-8 string S to lower case, if possible.

 -- Function: void utf8_wc_strupper (unsigned *STR)
     Converts each character from the wide character string STR to uppercase, if applicable.

 -- Function: void utf8_wc_strlower (unsigned *STR)
     Converts each character from the wide character string STR to lowercase, if applicable.

Additional functions
--------------------

 -- Function: unsigned * utf8_wc_strdup (const unsigned *S)
     Returns a pointer to a new wide character string which is a duplicate of the string S.  Memory for the new string is obtained with malloc(3), and can be freed with free(3).

 -- Function: unsigned * utf8_wc_quote (const unsigned *S)
     Quotes occurrences of backslash and double-quote in S by prefixing each of them with a backslash.  The return value is allocated using malloc(3).

 -- Function: int utf8_quote (const char *STR, char **SPTR)
     Quotes occurrences of backslash and double-quote in S by prefixing each of them with a backslash.  On success stores the result (allocated with malloc(3)) in SPTR, and returns 0.  On error, returns -1 and sets errno to the one of the following:

     ENOMEM
          Not enough memory to allocate the return buffer.

     EILSEQ
          An invalid wide character is encountered.

 -- Function: size_t utf8_wc_hash_string (const unsigned *WS,
     size_t N)
     Compute a hash code of WS for a symbol table of N buckets.

 -- Function: int dico_levenshtein_distance (const char *A,
     const char *B, int FLAGS)
     Computes Levenshtein distance between UTF-8 strings A and B.  The FLAGS argument is a bitwise or of one or more flags:

     0
          Default - compute Levenstein distance, treating both arguments literally.

     DICO_LEV_NORM
          Treat runs of one or more whitespace characters as a single space character (ASCII 32).

     DICO_LEV_DAMERAU
          Compute Damerau-Levenshtein distance.  This distance takes into account transpositions.

 -- Function: int dico_soundex (const char *WORD,
     char CODE[DICO_SOUNDEX_SIZE])
     Computes the Soundex code for the given WORD.  The code is stored in CODE.  Returns 0 on success, -1 if WORD is not a valid UTF-8 string.

      -- Define: DICO_SOUNDEX_SIZE
          This macro definition expands to the size of Soundex code buffer, including the terminal zero.

     Note that this function silently ignores all characters, except Latin letters.

util
====

 -- Function: char * dico_full_file_name (const char *DIR,
     const char *FILE)

 -- Function: size_t dico_trim_nl (char *BUF)

 -- Function: size_t dico_trim_ws (char *BUF)

xlat
====

 -- struct: xlat_tab

          struct xlat_tab {
              char *string;
              int num;
          };

 -- Function: int xlat_string (struct xlat_tab *TAB,
     const char *STRING, size_t LEN,
     int FLAGS, int *RESULT)
 -- Function: int xlat_c_string (struct xlat_tab *TAB,
     const char *STRING,
     int FLAGS, int *RESULT);

     XLAT_ICASE