#define xMemCheck


# ifndef __wimp_h
# include "wimp.h"
# endif


#define SPEAKING_VERSION

//#define ARGO_IMPORT


#define N_TEXT_DATA  16        /* max. number of text records */


#define SWI_SPEAK   0x4ad80 + os_X

#define FILETYPE_HTML    0xfaf
#define FILETYPE_URL     0xb28


#define wimp_M_URL   0x4af80   /* message to browser */

#define message_OLEOpenSession     0x80e21
#define message_OLEOpenSessionAck  0x80e22
#define message_OLEFileChanged     0x80e1e
#define message_OLECloseSession    0x80e23





#define ART_FILE_VERSION  4

#define CARD_FILE_VERSION  1


/* lock macros */
#define LOCK_2   0x10004      /* allow only debatch */


/* internet news transports */
#define X_VOYAGER   1
#define X_NEWSHOUND 2
#define X_ANT       3
#define X_TERMITE   4

/* internet mail transports, where different from above */
#define X_POP       2
#define X_FREESMTP  5
#define X_POPSTAR   6
#define X_HERMES    7

/* transport_opts values */
#define TOPS_ENVS_FILES  0x0001
#define TOPS_MAIL_MULT   0x0002
#define TOPS_MAIL_CRLF   0x0004
#define TOPS_MAIL_ANT    0x0008
#define TOPS_MAIL_FROM   0x0010
#define TOPS_MAIL_DOT    0x0020
#define TOPS_MAIL_ENV_DOMAIN 0x0040

#define TOPS_NEWS_DOT    0x0100
#define TOPS_NEWS_MULT   0x0200
#define TOPS_NEWS_FETCH  0x0400
#define TOPS_NEWS_CRLF   0x0800
#define TOPS_NEWS_ANT    0x0080

#define TOPS_VOYAGER     0x1000


/* browsers */
#define X_WEBVOYAGE  1
#define X_ARCWEB     2
#define X_FRESCO     3


#define MAIL_BUTTON_BAR_HEIGHT 176
#define MAIL_BUTTON_BAR_HEIGHT2 324
#define NEWS_BUTTON_BAR_HEIGHT 224
#define NEWS_BUTTON_BAR_HEIGHT2 272


#define HELP_ADDRLIST 'a'
#define HELP_ADDRBOOK 'A'
#define HELP_BOXLIST  'b'
#define HELP_BOXEDIT  'B'
#define HELP_COLR     'c'
#define HELP_OPDISPL  'd'
#define HELP_DELIVERY 'D'
#define HELP_OPSPELL  'e'
#define HELP_SPELL    'E'
#define HELP_FIND     'f'
#define HELP_OPFILTER 'F'
#define HELP_NGLIST   'g'
#define HELP_NGEDIT   'G'
#define HELP_KILLLIST 'k'
#define HELP_FILTER   'K'
#define HELP_LIST     'L'
#define HELP_MAIL     'M'
#define HELP_OPNEWS   'n'
#define HELP_NEWS     'N'
#define HELP_OPMISC   'o'
#define HELP_POSTLIST 'p'
#define HELP_PGP      'P'
#define HELP_REPLY    'R'
#define HELP_OPSPEAK  's'
#define HELP_USERLIST 'u'
#define HELP_USER     'U'
#define HELP_VIEW     'V'
#define HELP_EXPORT   'X'
#define HELP_SUBSET   'Z'

#define CARD_INDEX_EXTRA 1000   /* extra room in index file */
#define TEXT_EXTRA       2500   /* extra spac when allocating text buffers */
#define TEXT_BUF_MIN     5000
#define MIN_ART_COMPACT  10000     /* don't compact article file with less free-space */
#define N_ATTACHMENTS    6
#define N_MARKED_HEADER_LINES 20


#define BOX_EXTERN       58     /* ordinary boxes are 0-57 */
#define BOX_BIN          62
#define BOX_DELETED      63
#define N_BOXES          64      /* must be <= n.article.files, for holding passwords */
#define N_BOXES_EXTERN   BOX_BIN-BOX_EXTERN
#define N_MAIL_BOX       32


#define EDIT_STANDARD	0
#define EDIT_WIPEOUT	1
#define EDIT_EDIT	2

/* text window types */
#define X_VIEW          0
#define X_VIEW2         1   /* secondary viewer window */
#define X_MAIL		2
#define X_NEWS		3

/* save, export, print, options */
#define SAVE_REMOVESIG	1
#define SAVE_INTERNET	2
#define SAVE_SHORTHDR	4
#define SAVE_ORIGHDR    8
#define SAVE_RNEWS      16
#define SAVE_FORMFEEDS  32
#define SAVE_FROM       64
#define SAVE_SUBJ_HDR  0x200
#define PRINT_SYSTEM_FONT  32


#define ENCODE_TEXT     0
#define ENCODE_QUOTED   1
#define ENCODE_RICH     2
#define ENCODE_UUE      3
#define ENCODE_BASE64   4
#define ENCODE_BASE64_SINGLE  5   /* not MIME */
#define ENCODE_8BIT     6
#define ENCODE_TEXT_NO_HEADER  7  /* not MIME, eg. message which is a single part HTML */
#define ENCODE_MIMEUUE  8   /* Content-type: uuencode */
#define ENCODE_YENC     9
#define ENCODE_MIMEXUUE 10   /* Content-type: x-uuencode */
#define ENCODE_TEXT_NO_HEADER_Q  11  /* not MIME, eg. message which is a single part HTML, quoted printable */



typedef struct {
   char *mnem;
   int  value;
} MNEM_TAB;


typedef struct {
   char *mnem;
   int  value;
   int  len;
} MNEM_TAB2;




/* index card */
/* NOTE: 'status' field must in first 16 bytes */

#define ART_ADDR_MASK    0xffffff    /* 24 bits */
#define ART_LENGTH_MASK  0xffffff    /* 24 bits card.alength */
#define DATE_MASK       0x3ffffff
#define BOX_MASK       0xfc000000
#define COLR_MASK      0x07000000
/* #define SQUASHED_MASK  0x01000000    bit 24 */
/* #define INET_HDR_MASK  0x02000000    bit 25 */

#define STATUS_BIT_CROSSPOST 0x20   /* in ->user */
#define SQUASHED_MASK  0x40
#define INET_HDR_MASK  0x80

#define STATUS_MASK      0x07
#define STATUS_MASK2     0x0f    /* including "replied" bit */
#define STATUS_BIT_REPLIED 0x08
#define STATUS_BIT_OG    0x10
#define STATUS_BIT_NEWS  0x20
#define STATUS_BIT_HDR_ONLY 0x40
#define STATUS_BIT_RE    0x80

/* status bits in n_cats */
#define STATUS_BIT_CC       0x80
#define STATUS_BIT_ATTACH   0x40
#define STATUS_BIT_MAILLIST 0x20

#define STATUS_NEW       1    /* status=0 is NEW+FETCHED  */
#define STATUS_UNREAD    3    /* status=2 is UNREAD+FETCHED */
#define STATUS_MARKED    4
#define STATUS_LOCKED    5
#define STATUS_READ      6
#define STATUS_HIDDEN    7
#define STATUS_FETCHING   0xa   /* requested full body */
#define STATUS_DRAFT      0xf   /* open into a write news/mail window */

#define N_REFS_MASK   0x1f    /* use bottom 5 bits */
#define N_CATS_MASK   0x1f    /* use bottom 5 bits */


typedef struct {
   int    addr;            /* article address.  bits 24-31 file no. bits 0-23 addr in file */
   unsigned int alength;   /* article length.   bits 24-26 colour, bits 27-31 file type */
   unsigned int date_box;  /* bits 26-31 BOX, 25=Internet Header, 24=SQUASHED,
                              bits 0-23:  y << 16, month/day*144  time(*10mins)  Year since 1970 */

   char   source;          /* code for source, eg. newsgroup */
   char   status;          /* bits 0-2 status,  bit 3 replied,    bit 4 outgoing message,
                              bits 5 news (not mail),  bit 6 header only,  bit 7 a reply (Re:) */
   char   n_cats;          /* bits 5,6,7 (status_other2) bit 5 maillist, bit 6 attachment, bit 7 cc */
   char   d_keywords;
   char   d_title;
   char   d_author;
   char   d_comment;
   char   d_end;           /* number of bytes in 'data' */

   /* data[] must be half-word aligned */
   char   data[0x180];         /* variable data, in order:
                                categories (list of shorts)(no terminator)
                                strings: keywords, title, author, comment */
}  CARD_OLD;




typedef struct {
   int    addr;            /* article address.  bits 24-31 file no. bits 0-23 addr in file */
   unsigned int alength;   /* article length.   bits 24-26 colour, bits 27-31 file type */
   unsigned int date_box;  /* bits 26-31 BOX,
                              bits 0-25:  y << 18, month/day*576  time(*2.5mins)  Year since 1970 */
                              /* dates OK up to 1970+256 */

   char   source;          /* code for source, eg. newsgroup or mailing list */
   char   n_refs;          /* bits 0-4 num. of 4-byte references at start of Data */
   char   status;          /* bits 0-2 status,  bit 3 replied,    bit 4 outgoing message,
                              bits 5 news (not mail),  bit 6 header only,  bit 7 a reply (Re:) */
   char   user;            /* bits 0-4 user number + 1 (0=none),
                                7=Internet Header, 6=Squashed, 5=multiple-copies */
   char   n_cats;          /* bits 0-4 n_cats, (status_other2) bit 5 maillist, bit 6 attachment, bit 7 cc */
   char   d_keywords;
   char   d_title;
   char   d_author;
   char   d_comment;
   char   d_end;           /* number of bytes in 'data' */

   /* data[] must be half-word aligned */
   short  score;           /* byte 22 */
   unsigned int  msgid;    /* hash code of message-id, 0 if none */
   unsigned int  parent;   /* hash code of referenced parent, 0 if none */
   char   data[0x180];     /* starts at byte 32.   variable data, in order:
                              categories (list of shorts)(no terminator)
                              strings: keywords, title, author, comment */
}  CARD;

typedef struct {
   int    addr;
   unsigned int alength;
   unsigned int date_box;
   char   source;
   char   spare;
   char   status;
   char   user;
   char   n_cats;
   char   d_keywords;
   char   d_title;
   char   d_author;
   char   d_comment;
   char   d_end;
   char   data[0x180];         /* starts at byte 22.   variable data, in order:
                                categories (list of shorts)(no terminator)
                                strings: keywords, title, author, comment */
}  CARD_OLD3;



/* bits in ng_flags */
#define NG_HEADFETCH     1
#define NG_SUBJECT_TAGS  2
#define NG_READ_ONLY     4
#define NG_DIGESTS       8
#define NG_DELETE_LOG_COPY 16

typedef struct {
   char  length;   /* must be first entry */
   char  selected;
   char  position;
   char  active;
   char  ng_flags;
   char  expiry;
   char  box;
   char  source;
   char  moderated;
   char  ng_num;
   char  voy_x;
   char  server[4];
   int   serial;
   int   serial2;
   char  maillist;    /* bit 0=maillist */
   char  default_user;
   char  strip_n_chars;   /* strip N chars from the start of the subject */
   char  sign_messages;
   char  signature[12];
   char  name[6];   /* variable length */
}   NEWSG;





#define CD_STRLEN  179
#define CD_N_CATS  32
#define CD_N_REFS  32

typedef struct {
   CARD *card_ptr;
   int   addr;
   int   index_ptr;
   char **text_anchor;
   char  filetype;
   char  status_other;
   char  status_other2;
   char  colour;
   char  ftype;          /* file type code. 0=text, 1=html */
   char  replied;
   char  reply;
   char  n_cats;
   char  n_refs;
   char  expiry;
   char  status;
   char  status2;        /* bits 0-3 of cptr->status */
   char  text_changed;
   char  header_changed;
   char  user;           /* user number + 1  (0=none) */
   char  charset_title;
   char  charset_author;
   int   docbox;
   int   copy_box;       /* >0 (box number + 1) to copy into */
   int   date;
   int   source;
   int   msgid;
   int   parent;
   int   score;
   int   flags;
   int   text_offset;    /* start of text from article file entry */
   int   text_start;     /* start of text from anchor */
   int   text_start_body;  /* after internet headers */
   int   text_length;
   NEWSG *ng_found;
   short cat_codes[CD_N_CATS];
   char  cats[CD_STRLEN+1];
   char  title[CD_STRLEN+1];
   char  author[128];   /* to match the A.Viewer and Write Mail templates */
   char  keywords[CD_STRLEN+1];
   char  comment[CD_STRLEN+1];
   char  size_str[16];
   char  message_id[180];
   unsigned int references[CD_N_REFS];
}  CARD_EXPANDED;




typedef struct {
   int version;
   int n_cards;
   int today_date;
   int spare[13];
} CARD_HEADER;



typedef struct {
   int  version;
   int  n_articles;
   int  free_space;
   int  size;
   unsigned int  box_password[2];
   int  spare[2];
}  ART_FILE_HEADER;


#define MAGIC  0xb500a601   /* word to recognise start of each article during recovery */

typedef struct {
   unsigned int  magic;
   int  length;   /* bits 0-23. length including this header,   bit 31='free' */
} ART_HEAD;



/* killfile types */
#define KF_AUTHOR         1
#define KF_DOMAIN         2
#define KF_TITLE          3
#define KF_TITLE_CONTAINS 4
#define KF_MESSAGE_ID     5
#define KF_PATH           6
#define KF_NEWSGROUP      7
#define KF_HEADER         8
#define KF_TEXT           9
#define KF_CAPS          10
#define KF_NUM_GROUPS    11
#define KF_MESSAGE_ID2   12  /* same as KF_MESSAGE_ID */
#define KF_ENVELOPE_TO   13
#define KF_SOURCE        14
#define KF_ADDR_BOOK     15  /* is sender in the address book */
#define KF_CONTENT_TYPE  16
#define KF_OR          0x40
#define KF_AND_NOT     0x80


typedef struct {
   char type;      /* KF_AUTHOR etc */
   char box;       /* put article into this box i a match is found */
   char length;    /* length of 'string' */
   char flags;     /* bit 0 News, bit 1 Mail, bit 2 Maillists */
   char selected;  /* highlighted in Filters list */
   char active;
   char copy_box;  /* and a copy into (this box-1), unless this is zero */
   char colour;
   int  expiry;  /* date when this rule expires (internal format) or 0 for noe xpiry */
   char string[128];  /* variable length field, 128 is maximum length */
}  KILLFILE_1;



typedef struct {
   char type;      /* KF_AUTHOR etc */
   char box;       /* put article into this box if a match is found, BOX_BIN=discard, 255=no_effect */
   char length;    /* length of 'string' */
   char flags;     /* bit 0 News, bit 1 Mail, bit 2 Maillists, bit 3 Text, but 4 O/G */
   char selected;  /* highlighted in Filters list */
   char active;
   char copy_box;  /* and a copy into (this box-1), unless this is zero */
   char status;
   char type2;     /* Type for AND part */
   char string2;   /* displ. into string of the 2nd string */
   char keywords;  /* displ. into string for keywords to be added */
   char source;
   char priority;
   char regex;     /* bit 0 regex for string1,            bit 1 regex for string2,
                      bit 2 case sensitive,  bit 3 accent sensitive  for string1
                      bit 4 case sensitive,  bit 5 accent sensitive  for string2
                      bit 6 OR,  bit 7 AND NOT */
   char spare1;
   char score_op;
   short score;
   short category;
   int  expiry;  /* date when this rule expires (internal format) or 0 for noe xpiry */
   char string[256];  /* variable length field */
}  KILLFILE;



/* Categories Table */
/* NOTE: width of this table is used in standard_sorter in assemb */
typedef struct {
   unsigned short flags;      /* bit 0=selected */
   unsigned short catnum;     /* index into array of CATs. Number of this CAT or zero if unused */
   unsigned short right;      /* index into array of CATs, next at this level */
   unsigned short down;       /* index into array of CATs, first at next level down */
   unsigned short parent;     /* index of parent */
   unsigned short position;   /* position in the hierarchy */
   unsigned short count;      /* number of times used in article headers */
   unsigned short data;

   unsigned short name;       /* index into char data.  Zero terminated (lower case) */
   unsigned short comment;    /* index into char data.  Zero terminated */
}  CAT;



typedef struct {
   int  n_cats;       /* number of catagory numbers in use */
   int  max_cat;      /* highest numbered CAT entry */
   int  n_cat_chars;   /* size of char data */
   int  cat_start;   /* cat number of first */
   int  spare[14];
}  CAT_HEADER;



#define N_DISPLAY_TAB   24
#define N_SORT_LEVELS   4
#define N_SORT_DISPLAY_ITEMS  6



typedef struct {
   char sort_field;
   char sort_reverse;
   char display_items[3*N_SORT_DISPLAY_ITEMS +1];    /* display items for this sort level */
   char sort_field2;
} DISPLAY_LEVEL;

typedef struct {
   char name[32];
   short window_width;
   char warn;
   char direction;
   char threading;
   char spare1;
   char spare2;
   char spare3;
   DISPLAY_LEVEL level[N_SORT_LEVELS];
} DISPLAY;



/* Note: need tables for 'source', 'category' */

#define MAX_CARD_LENGTH    512


/* card sort fields */
#define CS_DATE		1
#define CS_CAT1		2
#define CS_AUTHOR	3
#define CS_TITLE	4
#define CS_SOURCE	5
#define CS_LENGTH       6
#define CS_STATUS	7
#define CS_MONTH        8
#define CS_CAT0         9
#define CS_DOMAIN       10
#define CS_SCORE        11
#define CS_YEAR         12
#define CS_BOX          13
#define CS_ADDRCOLR     14

/* card template fields */

#define CD_AUTHOR_LABEL  0
#define CD_SAVE        1
#define CD_AUTHOR	2
#define CD_DATE		3
#define CD_TITLE	4
#define CD_COMMENT	9
#define CD_SOURCE	5
#define CD_LENGTH	7
#define CD_CATS		8
#define CD_KEYS		10
#define CD_MAILTYPE     6
#define CD_CATS1       11

#define CD_PREV        12
#define CD_NEXT        13
#define CD_DELETE      14
#define CD_MKREAD      15
#define CD_MKLOCK      16
#define CD_EDIT        17
#define CD_PRINT       18
#define CD_SPELL       19
#define CD_LIPS        20
#define CD_HEADER      21
#define CD_BOXIN       22
#define CD_ARCHIVE     23
#define CD_LARGER      24
#define CD_STATUS_SPRITE 25
#define CD_THREAD      26
#define CD_FORMAT      27
#define CD_ADDRADD     28
#define CD_KILLFROM    29
#define CD_KILLSUBJ    30
#define CD_REFERENCES  31


/* pre-defined source codes */

#define SOURCE_OTHER    1
#define SOURCE_MAIL     2
#define SOURCE_NEWS     3





/* Fold Display Data */
/*********************/

#define N_FOLD_LEVELS   6
#define N_LISTS     12  /* num. of article lists */
#define N_ART_FILES 64      /* main article files */
#define N_ART_FILES_X  32   /* article files in an external box */
#define N_ART_FILES_TOT   N_ART_FILES+(N_ART_FILES_X * N_BOXES_EXTERN)



typedef struct foldrec {
   int  type;        /* 0=linear list of words, bits 28-31 contain level */
                     /* 1=category tree,  2=sources tree */
   CAT  *cat_data;   /* MUST BE at displ=4 in this table, used by standard_sorter */
   char box;                       /* derived from this box (if not -1) */
   char box_expansion;             /*  is the exansion of this box  (boxno + 1) */
   char hide_read;
   char open_levels;		   /* number of levels open */
   char cursor_level;
   char external_box;
   char search_text_result;        /* this list is a result of a search in article text */
   char redraw_flag;
   char thread_indent;
   char open_article_source;

   char *cat_chars;                /* strings for category name and comment */
   int  max_cats;
   int  max_cat_chars;
   CAT_HEADER cat_header;
   wimp_w window;
   wimp_w window_buttons;
   wimp_wind *w_template;
   dbox dbox_list;
   wimp_redrawstr workarea;
   int  cursor_ref;
   int  open_article_ref;
   int  n_lines;                   /* number of visible lines */
   int  n_entries;                 /* number of items in visibile part of list */
   int  n_entries_tot;             /* total number of entries */
   int  n_entries_max;             /* max size for number of items */
   int  n_selected;
   unsigned int *ixlist;
   int  enumerate;                 /* used when stepping through entries */
   int  enumerate_level;
   int  enumerate_count;
   int  enumerate_count2;
   int  threading_done;
   struct foldrec *parent;
   DISPLAY *display;
   int  display_levels;
   char name[20];
   int  cursor_vect[N_FOLD_LEVELS];
   int  open_ref[N_FOLD_LEVELS];   /* indices of opened item at each level */
   int  open_vect[N_FOLD_LEVELS];  /* position, within each level, of the opened item */
   int  n_open[N_FOLD_LEVELS];     /* number of items open at each level */
} FOLDREC;



#define N_CARDFILES  4

typedef struct {
   char *base;              /* memory allocated to card file */
   int  n_entries;         /* number of card entries (including those deleted) */
   int  length;
   char path[200];
   char name[24];
} CARDFILE_REC;



#define N_DEST_CHARS 300
#define N_SUBJECT 127    /* size of Subject field in Write News/Mail tenplates */
typedef struct {
   int  news_mail;    /* 0=AV, 1=extra AV, 2=mail, 3=news */
   int  follow_up_flag;
   int  mailing_list;    /* 1= reply to mailing list */
   int  ack;
   int  quoted;
   int  date_enc;     /* encoded date */
   int  refs_length;
   int  reply_to_in;
   int  reply_to_in_length;
   int  cc_start;
   int  cc_length;
   int  from;
   int  from_length;
   int  to_start;
   int  to_length;
   int  list_post_start;
   int  list_post_length;
   int  subject_start;
   int  subject_length;
   int  keep_subject;    /* keep subject from original message */
   int  newsgroups;
   int  encoding;      /* use quoted_printable */
   int  default_user;
   int  pgp;           /* bit 0=sign  bit 1=encrypt */
   int  ng_flags;
   int  supersede;
   int  no_request_ack;
   int  lock_log_copy;
   int  orig_cc_length;
   int  orig_cc_hash;
   char fname_out[12];
   char message_id[120];
   char dest[N_DEST_CHARS];

   char follow_up[80];
   char reply_to[80];
   char in_reply_to[80];
   char email_copy[80];
   char user_addr[80];
   char cc[256];
   char bcc[256];
   char newsgs[N_DEST_CHARS];
#ifdef deleted
   char title[128+4];   /* allow for Re:   template string length + 4 */
#endif
   char subject[990];   /* "subject: " + subject = 998, so subject = 989 + 0byte */
} ARTICLE_OUT;



/* address book */

typedef struct {
   short length;     /* must be first entry */
   char offset;      /* of url in data[] */
   char alias;       /* offset of alias in data[] */
   char colr;
   char flags;    /* bit0: clearsign, bit1: encrypt,
                     bit2: colour in article list, bit3: replace addr with name
                     bit4: lock mail log copy
                     bit5: use MIME not UUE ?? */
   char selected;
   char folder;
   char comment;     /* offset for comment data */
   char user;        /* which of our User email addresses to use */
   char sig;         /* offset to signature name */
   char wordwrap;
   char spare2;
   char spare3;
   char spare4;
   char spare5;
   char data[1];
} ADDR_BOOK;


typedef struct {
   short length;     /* must be first entry */
   char offset;      /* of url in data[] */
   char alias;       /* offset of alias in data[] */
   char colr;
   char flags;    /* bit0: clearsign, bit1: encrypt,
                     bit2: colour in article list, bit3: replace addr with name
                     bit4: lock mail log copy
                     bit5: use MIME not UUE ?? */
   char selected;
   char folder;
   char comment;     /* offset for comment data */
   char user;        /* which of our User email addresses to use */
   char sig;         /* offset to signature name */
   char wordwrap;
   char spare2;
   char spare3;
   char spare4;
   char spare5;
   char data[256+243];   /* as ADDR_BOOK, but with variable data allocated */
} ADDR_BOOK2;


typedef struct {
   char length;
   char offset;   /* of url in data[] */
   char alias;    /* offset of alias in data[] */
   char colr;
   char flags;
   char selected;
   char data[160];   /* as ADDR_BOOK, but with variable data allocated */
} ADDR_BOOK_OLD;


typedef struct {
   int  references;
   int  references_end;
   int  in_reply_to;
   int  in_reply_to_end;
   int  ack_receipt;
   int  ack_receipt_len;
   int  path;
   int  path_end;
   int  newsgroups;
   int  newsgroups_end;
   int  envelope_to;
   int  envelope_to_len;
   int  to;
   int  to_len;
   int  cc;
   int  cc_len;
   int  content_type;
   int  content_type_len;
   int  header_end;
   int  text_length;
   int  transfer_encoding;
   int  multipart_digest;
   int  supersedes;
   ADDR_BOOK *addr_book_entry;
} ARTICLE_IN;


#define USEROPT_NONEWS   0x01
#define USEROPT_NOMAIL   0x02
#define USEROPT_SIGN     0x20
#define USEROPT_ENCRYPT  0x40


typedef struct {
   char box;
   char log;
   char tags;
   char request_acks;
   char copy_box;
   char mail_list_server;
   char user_id_len;
   char position;
   char spare1;
   char spare2;
   char spare3;
   char flags;   /* bit 0 = don't allow news posts,
                    bit 1 = don't allow mail
                    bit 2 = show full address in writ mail window
                    bit 3 = don't send acks (not yet used)
                    bit 4 = don't include User Agent in reply header
                    bit 5 = always PGP sign
                    bit 6 = always PGP encrypt
                 */
   int  mail_password;
   char full_name[32];
   char signature[16];
   char email_addr[64];
} OPTIONS_MAILBOX;



typedef struct {
   int  displ;
   int  length;
   int  content_id;
   short ftype;
   char selected;
   char encoding;
   char name_displ;
   char name[64];
   char sprite[12];
} ATTACHMENT;


#define N_LINE_TAB  1500        /* max. lines of text */

typedef struct {
   wimp_w  w_text;
   wimp_w  w_card;
   dbox    dbox_card;
   wimp_w  w_attach;
   ARTICLE_OUT *art_out;
   char write_mail_tag;         /* to distinguish different Write Mail windows */
   char allow_edit;
   char text_type;              /* 0=read, 1=send mail, 2=send news */
   char lips_icon;              /* icon number for lips button */
   char selection;              /* is selection specified ? */
   char changed;
   char ext_edit;               /* 1= using external edit, do not display text */
   char ole;                    /* 1- OLE in progress */
   char attachments;            /* number of attachments present */
   char num_attach;             /* data allocated for this many attachments */
   char use_mime;               /* 1= MIME attachments, not UUE  2=PC-MIME */
   char encoding;
   char text_attachments;       /* 1= treat attachments as filetype=Text */
   char button_bar_expanded;
   char wordwrap;
   char charset;                /* 0=Latin1, others= iso-8859- number */
   char multi_alternative;      /* 1=multipart/alternative in header */
   char multi_encrypted;
   char n_newsgroups;           /* number of newsgroups in internet header */
   char followup_set;           /* 1= Followup-To: line in internet header */
   char minutes;                /* from the Date: line in the internet header, minutes+1 */
   char show_message_headers;
   char selected_user_num;
   char new_file;
   wimp_redrawstr  workarea;
   FOLDREC *fr;
   FOLDREC *parent;             /* 1-N_LISTS means article list */
   CARD *cptr;
   CARD *cptr_save;
   CARD_EXPANDED *cardex;


/* this section adjusted by move_up and move_down */
   int  text_start;
   int  internet_header;        /* end of internet header at start of text */
   int  internet_header2;       /* end of hidden part of internet header, before the reordered parts */
   int  region_start;
   int  region_end;
   int  speak_start;
   int  speak_end;
   int  text_body_end;          /* end of text part, from text_base.  Msg header may follow */
   int  sig_start;              /* start of sig.separator, from text_base */

   int  text_buf_size;
   char *text_base;
   int  text_length;
   int  extent_y;
   int  cursor_line;		/* line number with cursor */
   int  cursor_line_start;	/* start index of this line */
   int  cursor_index;		/* text index of cursor */
   int  filetype;
   int  last_cursor_index;
   int  spell_error_index;
   int  grad_caret;   /* ???? */
   int  n_lines;
   int  just_removed;      /* removed from its article list */
   int  x_index;                /* used by PAGE_UP, KEY_UP etc */
   int  prev_scroll_posn;       /* last y-scroll value */
   int  button_bar_height;
   int  remember_scroll;
   int  level_index;            /* for the title bar */
   int  level_total;            /* for the title bar */
   unsigned int last_change;
   unsigned int last_save;
   OPTIONS_MAILBOX *selected_user;          /* for replies */
   char selected_sig[16];
   char *status_sprite;
   ATTACHMENT *attach;
   int  boundary_string_len;
   char boundary_string[72];
   char fname_save[256];
   char *line_tab;
   int  n_line_tab;
} TEXTR;



/* data for boxes */
typedef struct {
   char name[24];
   char flags;      /* bit 0=strip_headers, 7=dont_hold_password
                           1=put replies in this box
                           2=expire unread artiticles */
   char expiry;
   char hide_read;
   char editable;
   char newsg_expiry;
   char indent;
   char archive_copy;   /* 1=copy not move to archive */
   char leave_unread;
   char hide_box;
   char default_user;
   char archive_to;
   char expire_to;
   char sort_on;
   char colour;
   char colour_ic;
   char colour_og;
   char position;
   unsigned int  box_password;
} BOX_OLD2;



/* flags */
#define BOX_STRIP_HEADERS       1
#define BOX_ANNOUNCE            2
#define BOX_EXPIRE_UNREAD       4
#define BOX_EDITABLE            8
#define BOX_LEAVE_UNREAD     0x10
#define BOX_ARCHIVE_COPY     0x20
#define BOX_DELETE_LOG_COPY  0x40
#define BOX_DONT_HOLD_PWORD  0x80

#define BOX_NEWSG_EXPIRY        1   /* use newsgroup expiry period */
#define BOX_MANUAL_EXPIRY       2   /* only manual expiry on this box */
#define BOX_EXPIRE_LOCKED       4   /* expire includes locked & marked */

typedef struct {
   char name[24];
   char flags;      /* bit 0=strip_headers, 1-announce delivery
                           2 = expire unread, 3 = editable,
                           4 = leave unread,  5 = archive copy
                           6 = delete log copy when message is received
                           7 = don't hold password */
   char expiry;
   char hide_read;
   char log_box;
   char expiry_flags;
   char indent;
   char spare1;
   char spare2;
   char hide_box;
   char default_user;
   char archive_to;
   char expire_to;
   char sort_on;
   char colour;
   char colour_ic;
   char colour_og;
   char position;
   unsigned int  box_password;
} BOX;


typedef struct {
   char type;      /* 1=mail, 2=news, 5=held mail, 6=held post */
   char selected;
   char wide;
   char attachment;
   CARD *card;
   int  size;
   char fname[12];
   char title[40];
   char author[40];
} POSTED_LIST;



typedef struct {
   int  type;
   int  x, y;
   char *title;
   int  butbar_height;
   int  width;
   int  n_entries;
   int  help_type;
   int  n_selected;
   int  open;
   int  max_entries;
   char *data_ptr;
   void **index_ptr;
   int  y0;
   wimp_w  w_list;
   wimp_w  w_buttons;
   wimp_wind *button_template;
   wimp_redrawstr workarea;

} BLIST;

#define BLIST_MAX     8    /* highest numbered blist */

#define BLIST_BOXES   1    /* article boxes */
#define BLIST_MBOXES  2    /* mailboxes */
#define BLIST_POSTED  3    /* list of posted articles, awaiting sending */
#define BLIST_NEWSG   4    /* newsgroup management */
#define BLIST_KILL    5    /* killfile */
#define BLIST_ADDR    6    /* address list */
#define BLIST_PGP     7    /* PGP keyring */
#define BLIST_MLIST   8    /* mailing lists */

/* index list */
/* bits 0-22  index/4 into card file
   bits 23-24 selection level
   bit  25    marked for selection (during search)
   bits 27-31 listing level
*/
#define IXLIST_MASK     0x007fffff   /* 23 bits */
#define IXLIST_LEVEL    0xf8000000   /* must be the top bits */
#define IXLIST_SELECTED 0x03800000   /* bits 23-25 */
#define IXLIST_MARKED   0x04000000   /* bit 26 */
#define IXLEV           27           /* shift factor for IXLIST_LEVEL */
#define IXSEL           23           /* shift factor for IXLIST_SELECTED */
#define IXSELB          0x7          /* bit mask for IXLIST_SELECTED bits */
#define IXLIST_N_LEVELS  32



#define BLACK       0x00000000
#define PGREY       0xbbbbbb00
#define DGREY       0x44444400
#define WHITE       0xffffff00
#define CYAN        0xffbb0000

#define RED         0x0000dd00

#define RED2    0x2200cc00
#define ORANGE  0x0066dd00
#define YELLOW  0x00bbdd00   /* 00bbbb00 */
#define GREEN   0x00885500
#define BLUE    0xaa220000
#define PURPLE  0x88008800
#define GREY    0x55555500
#define GREY6   0x66666600
#define LTBLUE  0xdd990000
#define BROWN   0x00557700


#define F_KEY       0x180
#define F_KEY_SHIFT 0x190
#define F_KEY_CTRL  0x1a0
#define F_KEY_SHIFT_CTRL 0x1b0

#define KEY_TAB     0x18a
#define KEY_COPY    0x18b
#define KEY_CT_COPY 0x1ab
#define KEY_SHIFT_TAB 0x19a

#define KEY_LEFT    0x18c
#define KEY_RIGHT   0x18d
#define KEY_DOWN    0x18e
#define KEY_UP      0x18f

#define KEY_SH_LEFT 0x19c
#define KEY_SH_RIGHT 0x19d
#define KEY_SH_DOWN 0x19e
#define KEY_SH_UP   0x19f

#define PAGE_DOWN   0x19e
#define PAGE_UP     0x19f

#define KEY_CT_LEFT 0x1ac
#define KEY_CT_RIGHT 0x1ad
#define KEY_CT_DOWN  0x1ae
#define KEY_CT_UP   0x1af

#define KEY_END     0x18b
#define KEY_HOME    0x1e





/*  OPTIONS */
/************/


#define N_FONTS  4

#define FONT_LIST    0
#define FONT_PRINT   1
#define FONT_TEXT    2
#define FONT_REPLY   3

#define COLR_TEXTW   0
#define COLR_ALIST   1
#define COLR_LISTS   2

#define SPELL_PHONETIC  1
#define SPELL_TYPO      2
#define SPELL_QWERTY    4
#define SPELL_SWAP_B_D  8
#define SPELL_D_T_AFTER_N 16

typedef struct {
   char name[64];
   int  height;
   int  width;
   int  spacing;
   int  colour;
   int  background;
} OPTIONS_FONT;



typedef struct {
   int  text_width;
   int  spare[7];
   OPTIONS_FONT font[N_FONTS];  /* list, subset, textview, textreply */
} OPTIONS_DISPLAY;





      typedef struct {
         char box;
         char log;
         char tags;
         char request_acks;
         char copy_box;
         char mail_list_server;
         char spare2;
         char spare3;
         int  spare;
         int  mail_password;
         char user_id[24];
         char full_name[32];
         char mnemonic[16];
         char domain[40];
      } OPTIONS_MAILBOX_OLD;


      typedef struct {
         OPTIONS_DISPLAY d;

         char  options_version;   /* start at 8 */
         char  news_transport;
         char  mail_transport;
         char  spare10;

         char allow_expiry;
         char news_backups;
         char news_box;
         char news_log;

         char mail_backups;
         char main_user;
         char edit_style;
         char speak_tayt;

         char speak_title;
         char speak_next;
         char speak_next_unread;
         char speak_announcements;

         char speak_voice[4];

         char any_read;         /* any articles read since the last fetch ? */
         char confirm_delete;   /* 0=confirm all, 1=confirm-locked, 2=allow all */
         char news_tags;
         char text_box;

         char news_header_extra;
         char print_options;
         char export_options;
         char save_options;

         char send_mail_acks;
         char junk_box;
         char addrlist_translate;
         char initial_select_user;
         char expire_active_threads;
         char maillist_box;
         char xx_update;   /* 2, used to control auto setting of options when upgrading versions */
         char ext_edit;
         short box_list_x;
         short box_list_y;
         char colours[4];  /* TextW, AList, Lists */

         char spare1;
         char spare2;
         char viewer_wordwrap;
         char mail_8bit;   /* used 8bit rather than quoted-printable for mail */
         char autosave;    /* in minutes */
         char define_text_colrs;
         char article_viewer_type;
         char use_mime;
         char speak_skip_addresses;
         char thread_open;   /* 1=open 1st article in thread, 2=open 1st unread article in thread */
         char text_font_toggle;
         char reply_wordwrap;

         /* spellcheck options */
         char spell_depth;
         char spell_opts;
         char check_as_you_type;
         char open_on_error;


         char newshound_mnem[4];
         int  spare20[5];

         char domain[40];
         char u_name[40];
         char organization[80];
         int  text_colrs[8];

         OPTIONS_MAILBOX_OLD mailbox[N_MAIL_BOX];

         char news_in[128];
         char news_out[128];
         char mail_in[128];
         char mail_out[128];
         char mail_envs[128];
         char ngroups_data[128];
         char save_path[150];
      } OPTIONS_OLD;







typedef struct {
   OPTIONS_DISPLAY d;

   char  options_version;   /* start at 8 */
   char  news_transport;
   char  mail_transport;
   char  spare10;

   char allow_expiry;
   char news_backups;
   char xnews_box;
   char xnews_log;

   char mail_backups;
   char main_user;
   char edit_style;
   char speak_tayt;

   char speak_title;
   char speak_next;
   char speak_next_unread;
   char speak_announcements;

   char speak_voice_old[4];   /* moved to a 6 byte array for v1.11g 27.3.99 */

   char new_to_unread;  /* change New to Unread 0=by box, 1=by source, 2=all, 3=none */
   char confirm_delete;   /* 0=confirm all, 1=confirm-locked, 2=allow all */
   char news_tags;
   char xtext_box;

   char news_header_extra;
   char print_options;
   char spare_export_options;
   char save_options;

   char send_mail_acks;
   char xjunk_box;
   char addrlist_translate;
   char initial_select_user;
   char expire_active_threads;
   char xmaillist_box;
   char xx_update;   /* 2, used to control auto setting of options when upgrading versions */
   char ext_edit;
   short box_list_x;
   short box_list_y;
   char colours[4];  /* TextW, AList, Lists */

   char skip_thread;    /* skip, mark-read, delete */
   char dont_compress;  /* don't compress stored articles */
   char addr_expand;  /* expand to full address into fields */
   char mail_8bit;   /* used 8bit rather than quoted-printable for mail */
   char autosave;    /* in minutes */
   char define_text_colrs;
   char article_viewer_type;
   char use_mime;
   char speak_skip_addresses;
   char thread_open;   /* 1=open 1st article in thread, 2=open 1st unread article in thread */
   char text_font_toggle;
   char reply_wordwrap;

   /* spellcheck options */
   char spell_depth;
   char spell_opts;
   char check_as_you_type;
   char open_on_error;


   char newshound_mnem[4];
   char crossposts;
   char reject_unknown_addresses;
   char users_menu;       /* show full address in users menu */
   char restrict_height;  /* restrict lower edge of windows, 1=dont cover icon bar, 2=save position */
   char pgp_ram;
   char poll_og;     /* poll outgoing message queue */
   char box_show_locked;  /* indicate locked articles in the boxes list */
   char leave_undelivered_mail;  /* return undelivered mail to the input queue */
   char auto_debatch;     /* period (minutes) for auto-debatching */
   char auto_debatch2;    /* spare, could use to have different mail and news auto-debatch */
   char reset_av_position;
   char close_og_list;
   char multi_task;
   char move_aviewer;     /* don't return article viewer to standard posn for each new article */
   char speak_speed;
   char speak_volume;
   char store_message_ids; /* store message ids in cards */
   char search_options;
   char spell_capitals;    /* 1=don't spellcheck if all capitals */
   char viewer_wordwrap;


   char domain[40];
   char u_name[40];
   char organization[80];
   int  text_colrs[16];

   char button_bar_size[6][4];  /* index by text_type*2 + variant */

   /* boxes - checked in dbox_boxes_handler()  */
   char news_box;            /* default for Newsgroups */
   char news_log;
   char returned_box;
   char text_box;
   char draft_box;
   char filter_box;            /* default for Filters */
   char postmaster_box;      /* for undelivered mail */
   char mlist_box;           /* for mailing lists */
   char spare3_box;

   char n_mail_box;

   /* window positions */
   /* 0=article viewer, 1=write mail/news, 3=article list
      4=spellcheck window, 5+ Blists */
   short position_x[16];
   short position_y[16];
   short position_y0[16];
   short position_width[4];

   char speak_speed_announce;
   char spell_skip_tags;
   char leave_undelivered_news;
   char tabs;               /* number spaces for tab positions */
   char speak_voice[6];
   char speak_punct;
   char local_mail;
   char keep_references;
   char input_status;       /* obey Status: R line in header */
   short export_options;
   short filter_expire;
   short filter_show_tick;
   short filter_discard;
   short filter_set_read;

   char index_autosave;    /* timer to save articles.cards */
   char browser_type;      /* 0=other, 1=fresco */
   char filter_score_box;
   char limit_recipients;  /* split email's address list */
   int spare30[7];

   char news_in[128];
   char news_out[128];
   char mail_in[128];
   char mail_out[128];
   char mail_envs[128];
   char ngroups_data[128];
   char save_path[150];

   OPTIONS_MAILBOX mailbox[N_MAIL_BOX];
} OPTIONS;


#define N_VOICES  6
#define LEN_VOICE_NAME  24

typedef struct {
   char voicename[N_VOICES][LEN_VOICE_NAME];
} VOICES;

