#ifndef CONF_H
#define CONF_H  1


/*! \addtogroup CONF */
/* @{ */


/* ========================================================================== */
/* Constants */

/*! \brief Number of entries in global configuration array */
#define CONF_NUM  38


/* ========================================================================== */
/* Data types */

/*! \brief IDs for use as index in configuration array
 *
 * \attention
 * Don't forget to modify the number of entries \ref CONF_NUM after adding or
 * removing a configuration entry!
 *
 * \note
 * A C90 compiler is required to assign the values starting from zero without
 * holes by default. We force the default behaviour explicitly only to make
 * it more obvious for humans what values are used.
 */
enum conf_entry
{
   CONF_POS_X = 0,                 /*!< Main window X position */
   CONF_POS_Y = 1,                 /*!< Main window Y position */
   CONF_SIZE_X = 2,                /*!< Main window X size */
   CONF_SIZE_Y = 3,                /*!< Main window Y size */
   CONF_TILE_X = 4,                /*!< Main window X tiling */
   CONF_TILE_Y = 5,                /*!< Main window Y tiling */
   CONF_SERVER = 6,                /*!< NNTP server hostname or IP address */
   CONF_SERVICE = 7,               /*!< NNTP service name or TCP port */
   CONF_ENC = 8,                   /*!< NNTP connection encryption algorithm */
   CONF_AUTH = 9,                  /*!< NNTP server authentication algorithm */
   CONF_IMMEDAUTH = 10,            /*!< Flag for immediate authentication */
   CONF_USER = 11,                 /*!< NNTP server authentication account */
   CONF_PASS = 12,                 /*!< NNTP server authentication password */
   CONF_CAC = 13,                  /*!< Clamp article count to this value */
   CONF_FROM = 14,                 /*!< "From" name and E-Mail address */
   CONF_REPLYTO = 15,              /*!< "Reply-To" name and E-Mail address */
   CONF_DOMAIN = 16,               /*!< Domain Name (without hostname part) */
   CONF_NEWSRC = 17,               /*!< Pathname of shared newsrc file */
   CONF_SCORERC = 18,              /*!< Pathname of shared scorerc file */
   CONF_INTRO = 19,                /*!< Introduction line format */
   CONF_ORGANIZATION = 20,         /*!< Organization name poster is part of */
   CONF_TVIEW = 21,                /*!< Flag for threaded view */
   CONF_ONLYUR = 22,               /*!< Flag for only unread articles */
   CONF_CANCELKEY = 23,            /*!< Secret for Cancel-Key */
   CONF_PPROC = 24,                /*!< Pathname of external postprocessor */
   CONF_EDITOR = 25,               /*!< Pathname of external editor */
   CONF_QUOTESTYLE = 26,           /*!< Quoting style (for citation) */
   CONF_QUOTEUNIFY = 27,           /*!< Unification of quoting style */
   CONF_TESTGRP_ERE = 28,          /*!< ERE pattern to match test groups */
   CONF_TESTGRP_KWORDS = 29,       /*!< Keywords to set for test groups */
   CONF_CRL_UPD_IV = 30,           /*!< TLS certificate CRL update interval */
   CONF_CRL_UPD_TS = 31,           /*!< TLS certificate CRL update timestamp */
   CONF_CRL_UPD_C = 32,            /*!< TLS certificate CRL update choice */
   CONF_UTVIEW_AN = 33,            /*!< Sort unthreaded view by article num. */
   CONF_INV_ORDER = 34,            /*!< Sort articles with inverted order */
   CONF_NO_OVER = 35,              /*!< NNTP driver don't use overview */
   CONF_DIST_SUGG = 36,            /*!< Use distribution suggestions */
   CONF_COMPRESSION = 37           /*!< NNTP driver negotiates compression */
   /* !!! Set 'CONF_NUM' above to the first unused value !!! */
};

/*! \brief Data types of configuration array entries */
enum conf_entry_type
{
   CONF_TYPE_INT,                  /*!< Entry is of integer type */
   CONF_TYPE_STRING                /*!< Entry is of string type */
};

/*! \brief Configuration array entry value */
union conf_entry_val
{
   int  i;                         /*!< Integer entry value */
   const char*  s;                 /*!< String entry value */
};

/*! \brief Configuration array entry */
struct conf
{
   const char*  label;             /*!< Name before the colon */
   enum conf_entry_type  type;     /*!< Type of entry */
   union conf_entry_val  val;      /*!< Value of the entry behind the colon */
   int  found;                     /*!< Flag indicating entry in config file */
};


/* @} */


/* ========================================================================== */
/* Variables */

extern struct conf  config[CONF_NUM];
extern int  conf_ephemeral_passwd;


/* ========================================================================== */
/* Function prototypes */

extern int  conf_load(struct conf*);
extern int  conf_store(struct conf*);
extern void  conf_delete(struct conf*);
extern int  conf_string_replace(struct conf*, const char*);


#endif  /* CONF_H */

/* EOF */
