#include <stdio.h>
#include <time.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

typedef long bool;

#define FALSE 0
#define TRUE !FALSE

#include "os.h"
#include "strings.h"
#include "komums.h"
#include "misc.h"
#include "groups.h"
#include "commands.h"
#include "kommands.h"
#include "writemsg.h"
#include "readmsg.h"
#include "select.h"

#define BASENAME "BillingKom"
#define VERSION  "1.0"
#define COPYRIGHT "1997-1998"

#define STRINGSFILE   "PROGDIR:BillingKom.texts"
#define GROUPSFILE    "PROGDIR:BillingKom.groups"
#define COMMANDSFILE  "PROGDIR:BillingKom.commands"

#define CFG_SUBJECTLINE       0
#define CFG_CLEARSCREEN       1
#define CFG_HIDEORGANIZATION  2
#define CFG_HIDEDISTRIBUTION  3
#define CFG_HILIGHTQUOTE      4
#define CFG_TEXTSTYLES        5
#define CFG_READOWN           6
#define CFG_SIGNALTOYOU       7
#define CFG_ESPERANTO         8

extern int linesonscreen;

extern bool brk;
extern bool carrierlost;
extern bool exitkom;

extern char currentgroup[100];
extern char currentfolder[100];

#define READARRAYSIZE 1000
#define BACKARRAYSIZE 1000

extern long readarray[READARRAYSIZE];
extern long backarray[BACKARRAYSIZE];

extern int readarraynum;
extern int backarraynum;

extern int backpos;
extern long lastread;

extern char loginusername[100];
extern char loginpassword[100];
extern char realname[100];

extern FILE *ownstdout;

extern long currentwidth;

extern struct flag flags[];
extern UMSAccount login;
extern char *strings[NUMSTRINGS];

extern struct command *firstcommand;
extern struct command *firsteditcommand;

extern struct group *firstgroup;
extern struct group *findnextgroup_cache;

struct flag
{
   char **name;
   char *umsname;
   bool set;
};

extern int cfg_Width;
extern int cfg_Lines;

extern bool arg_local;

struct receiver
{
   struct receiver *next;
   char name[100];
};

struct message
{
   long oldmsgnum;                 /* When editing a message */

   char oldattachname[100];        /* When editing a message with a file or
                                      when forwarding a message with a file */

   bool ismail;                    /* Set if a mail. Then receiverlist contains user names */
   char filename[L_tmpnam];        /* For the textfile with the message text */

   struct receiver *firstreceiver; /* linked list with all the receivers */
   long chainup;

   char folder[200];
   char subject[200];
   char attributes[200];
   char organization[200];
   char distribution[200];
   char replygroup[200];
   char replyname[200];
   char replyaddr[200];
   char attachname[200];
   char referid[200];
   char toname[200];
};

