/********************************************************************
 *                                                                  *
 *  MODULE    :  WVGLOB.H                                           *
 *                                                                  *
 *  PURPOSE   :  Contains all the global types and variables for    *
 *               WinVN.  Stylistically, this should probably be     *
 *               separated into several header files, but this is   *
 *               what you've got for now. WVDOC.C describes         *
 *               some of these structures.                          *
 *                                                                  *
 *******************************************************************/

/*
 * $Id: wvglob.h 1.87 1997/04/05 00:18:04 dumoulin Exp $
 */

#ifndef __WVGLOB__
#define __WVGLOB__

#include <Windows.h>
#include <sys/stat.h>

#ifdef _MSC_VER //MSVC

#define _sprintf sprintf
#define ALIGNED
#define PACKED 

#endif  

#ifdef __BORLANDC__

#include <string.h>
#include <stdarg.h>

#define _strnicmp  strnicmp
#define _stricmp   stricmp
#define _snprintf  snprintf
#define _vsnprintf vsnprintf
#define _sprintf   sprintf

int snprintf(char *buf, int len, const char *format,...);
int vsnprintf(char *buf, int len, const char *format, va_list args);

#include <io.h>
#define _open open
#define _close close
#define _filelength filelength
#define _O_RDONLY O_RDONLY
#define _getcwd getcwd


#include <ctype.h>
#define __isascii  isascii

#endif

#ifdef __WATCOMC__

#include <io.h>
#include <ctype.h>
#include <dos.h>

#define _open open
#define _close close
#define _filelength filelength
#define _getcwd getcwd
#define _chdir chdir
#define _putenv putenv
#define _tzset tzset
#define _read read
#define _write write
#define _eof eof
#define _snprintf _bprintf
#define snprintf _bprintf
#define _vsnprintf _vbprintf

#define _timezone timezone
#define TimeZone MyTimeZone

#define _S_IREAD S_IREAD
#define _S_IWRITE S_IWRITE

#endif

#ifdef __GNUC__

//#define GlobalAllocPtr(t,s)      malloc(s)
//#define GlobalReAllocPtr(p,s,t)  realloc(p,s)
//#define GlobalFreePtr(p)         free(p)
#define GlobalAllocPtr(f,c)        (GlobalLock(GlobalAlloc((f),(c))))
#define GlobalFreePtr(p)           (GlobalUnlockPtr(p),(WINBOOL)GlobalFree(GlobalPtrHandle(p)))
#define GlobalLockPtr(p)           ((WINBOOL)GlobalLock(GlobalPtrHandle(p)))
#define GlobalPtrHandle(p)         ((HGLOBAL)GlobalHandle(p))
#define GlobalReAllocPtr(p,c,f)    (GlobalUnlockPtr(p),GlobalLock(GlobalReAlloc(GlobalPtrHandle(p),(c),(f))))
#define GlobalUnlockPtr(p)         GlobalUnlock(GlobalPtrHandle(p))
#define AnsiLower(ch)              tolower((unsigned char)ch)
#define AnsiNext(ptr)              ((char *)ptr + 1)
#define AnsiUpper(ch)              toupper((unsigned char)ch)
#define IsMinimized(hwnd)          IsIconic(hwnd)
#define _fstrchr                   strchr
#define _fstrstr                   strstr
#define _sprintf                   sprintf
#define snprintf                   _snprintf
#define ultoa                      _ultoa

/*
#ifdef __cplusplus
 extern "C" {
#endif
int sprintf(char *buf, const char *format,...);
int vsprintf(char *buf, const char *format, va_list args);
//MDS already defined in my gcc environ...
//int _snprintf(char *buf, int len, const char *format,...);
//int _vsnprintf(char *buf, int len, const char *format, va_list args);
#ifdef __cplusplus
 }
#endif
*/
#endif

#ifdef _WIN32
#ifndef WIN32
#define WIN32
#endif
#endif

#ifdef WIN32
#ifndef _WIN32
#define _WIN32
#endif
#endif

/* these are supposed be defined in windowsx.h, but they aren't in mine! */
#if !defined( GET_WM_COMMAND_CMD ) || !defined( GET_WM_COMMAND_HWND ) // S.Yoshida #ifndef GET_WM_COMMAND_CMD
#ifdef _WIN32
#define GET_WM_COMMAND_CMD(wp, lp)  HIWORD(wp)
#define GET_WM_COMMAND_ID(wp, lp)   LOWORD(wp)
#define GET_WM_COMMAND_HWND(wp, lp) (HWND)(lp)
#else
#define GET_WM_COMMAND_CMD(wp, lp)  HIWORD(lp)
#define GET_WM_COMMAND_ID(wp, lp)   (wp)
#define GET_WM_COMMAND_HWND(wp, lp) ((HWND)LOWORD(lp))
#endif
#endif

#if !defined(GET_X_LPARAM) || !defined(GET_Y_LPARAM)
#ifdef _WIN32
#define GET_X_LPARAM(lp)   ((int)(short)LOWORD(lp))
#define GET_Y_LPARAM(lp)   ((int)(short)HIWORD(lp))
#else
#define GET_X_LPARAM(lp)  (LOWORD(lp))
#define GET_Y_LPARAM(lp)  (HIWORD(lp))
#endif
#endif

#ifdef _WIN32
#define huge far
#define LOPEN_READ      OF_READ
#define LOPEN_WRITE     OF_WRITE
#else
/*#define _int16 int */ /* (not defined in any 16 bit MSVC or MSVCNT 1.10) */
#define LOPEN_READ      READ
#define LOPEN_WRITE     WRITE
#endif

#ifndef UBIGINT
//#define UBIGINT unsigned long
#define UBIGINT unsigned __int64
#define UBIGINTFMT %I64d
#endif
#ifndef BIGINT
#define BIGINT __int64
#define BIGINTtoa _i64toa
#define atoBIGINT _atoi64
//#define BIGINTtoa ltoa
//#define atoBIGINT atol
#endif

#ifndef _int16
#define _int16 short int
#endif

#ifndef _int32
#define _int32 long int
#endif

#define int16 _int16
#define int32 _int32
#define uint16 unsigned _int16
#define uint32 unsigned _int32

#ifndef _WIN32
#define USE_3D_CONTROLS                 /* define this to use 3d controls (ctl3d.dll) */
#endif //no longer needed on Ver4+ Win32

#define COMM_TIMER_INTERVAL 100 /* in milliseconds */
#define INTERNAL_TIMEOUT 10      /* number of COMM_TIMER_INTERVAL's which needs one second */
#define INTERNAL_RESPONSE_TIMEOUT 30 /* number of COMM_TIMER_INTERVAL to wait for response */

#define DEFAULTPOSTWIDTH        78      /* warn user if wider than these */
#define BEGINPOSTWIDTH          72      /* 72 is recommended by de-netiquette for the first article */ 
#define BEGINMAILWIDTH          72
#define BEGINCANCELWIDTH        78
#define BEGINFORWARDWIDTH       72


#define BUFSIZE                 1024
#define TEMPBUFSIZE             1240
#define MAXHEADERLINE           1024
#define MAXREFERENCELINE  32767
#define MAXFINDSTRING           80
#define MAXDIALOGSTRING         255
#define MAXFILENAME             256
#define MAXENVVAR       40
#define MAXGROUPFILTERSIZE 1500
#define MAXFILTERS      5000

#ifndef _WIN32
#//define MAX_PATH                        1024
#define LPTSTR  char far *
#define LPCTSTR const char *
#endif

/* this has been increased for XOVER - some lines are *very* long */
#define MAXCOMMLINE             16384
#define MAXLINELEN              256
#define MAXINTERNALLINE         (MAXLINELEN+(3 * sizeof (TypLine) + sizeof (TypText)) )  // ADD (3 * sizeof (TypLine) + sizeof (TypText))   
#define MAXOUTLINE              255
#define MAXPOSTLENGTH           60000   /* max length for a posting/mail edit window */
#define MAXBOUNDARYLEN          70      /* max length for MIME boundary  */
#define MAXNEWGROUPSASK         200     /* limit of groups in newgroups dialog box */
#define MAXENCODINGTYPELEN      24      /* max len for encoding type - i.e. Base-64 */
#define MAXCONTENTTYPELEN       48      /* max len for content type - i.e. Application/Postscript */
#define MAXBOUNDARYLINE         70      /* max len for MIME boundary */
#define TOOLBARHEIGHT           27      /* height of toolbar */
#define TOOLBARHEIGHTMED        35
#define TOOLBARHEIGHTBIG        44
#define MAXSTATBARTEXT          255     /* maximum number of chars in status bar text  */
#define MAXSTATCOMMTEXT         20      /* maximum number of chars in status bar comm text  */
#define MAXTBBUTTONS            20      /* maximum number of tool bar buttons */


#define MAX_WHEEL_ENTRIES       10      /* allowes ScrollByWheel .. ScrollByWheel9 */


//#ifdef __cplusplus
//extern "C" {

class WVSeenDB;
class WVString;
class WVArticleAction;
class WVAddHdr;
//#endif

#include <time.h>
#include <commdlg.h>

/* Profile section headings */
#define OLD                             "Winvn"
#define ADMIN                   "Admin"
#define COMM                    "Communications"
#define AUTH                    "Authorization"
#define WVINTERFACE             "Interface"
#define PERSONAL                "Personal"
#define CONFIRM                 "Confirmation"
#define LOGGING                 "Logging"
#define MAIL_ADDRESSES  "Mail Addresses"
#define PRINTING    "Print"
#define SMARTFILER              "Smart Filer"
#define SEARCHES                "Searches"
#define GROUPLIST       "Group List"
#define ARTLIST                 "Article List"
#define ARTICLE                 "Article"
#define COMPOSE                 "Compose"
#define CODING                  "Coding"
#define ATTACH                  "Attachments"
#define INTERNATIONAL   "intl"
#define EXECUTE         "URL Execute"
#define MRUENTRIES              "Recent Files"
#define WARNEXTENTIONS          "WarnExeTypes"

/* Group sort choices */
#define STR_SORT_DATE      "Date"
#define STR_SORT_SUBJECT   "Subject"
#define STR_SORT_LINES     "Lines"
#define STR_SORT_THREADS   "Threads (strict)"
#define STR_SORT_THREADSUB "Thread/Subject"
#define STR_SORT_ARTNUM    "Article Number"
#define STR_SORT_FROM      "Author"

/* Ray Dunn:99/10
   Add new 2-level sort choices
*/
#define STR_DONT_SORT            "Dont Sort"
#define STR_SORT_DATE_TIME       "Date & Time"     
#define STR_SORT_DATE_SUBJECT    "Date & Subject" 
#define STR_SORT_DATE_LINES      "Date & Lines"
#define STR_SORT_DATE_ARTNUM     "Date & Article Number"
#define STR_SORT_DATE_FROM       "Date & Author"
#define STR_SORT_DATE_FILENAME   "Date & Filename"
#define STR_SORT_SUBJECT_DATE    "Subject & Date"
#define STR_SORT_SUBJECT_LINES   "Subject & Lines"
#define STR_SORT_SUBJECT_ARTNUM  "Subject & Article Number"
#define STR_SORT_SUBJECT_FROM    "Subject & Author"
#define STR_SORT_FROM_SUBJECT    "Author & Subject"
#define STR_SORT_FROM_DATE       "Author & Date"
#define STR_SORT_FROM_LINES      "Author & Lines"
#define STR_SORT_FROM_ARTNUM     "Author & Article Number"
#define STR_SORT_FROM_FILENAME   "Author & Filename"
#define STR_SORT_FILENAME        "Filename"
/* Ray Dunn:99/10:End */

typedef long TypLineID;

#ifdef __GNUC__
 #define ALIGNED __attribute__((aligned (4)))
#else
 #define ALIGNED
#endif

typedef struct structtextselect {
  long LineNum;                                 /* Line number when selecting text -- Line Ord  */
  int CharNum;                                  /* Character number when selecting text         */
  /* The 1st LineNum in the Doc and the 1st CharNum in the line are 0   */
} ALIGNED TextSelect;

typedef struct structdoc {
  HANDLE hFirstBlock;                   /* handle to first textblock in doc.        */
  HANDLE hLastBlock;                    /* unused.                                  */
  unsigned long TotalLines;             /* total # of lines in doc.                 */
  unsigned long LongestLine;            /* # of bytes in the longest line of doc    */
  unsigned long HeaderLines;            /* total number of lines in header of doc
                                                                   (incl. blank line) */
  unsigned long ActiveLines;            /* # of selected or otherwise active lines  */
  unsigned long CountedLines;           /* # of counted lines, as in subscr. groups */
  unsigned long BlockSize;              /* # of bytes in a textblock                */
  unsigned long SplitSize;              /* textblock split point in bytes           */
  HANDLE hCurAddBlock;                  /* hBlock to point at which to add lines.   */
  unsigned int AddOffset;               /* offset in bytes for point to add lines   */
  TypLineID AddLineID;                  /* LineID of place to add lines.            */
  HANDLE hCurTopScBlock;                /* hBlock of current top line of window     */
  unsigned int TopScOffset;
  TypLineID TopScLineID;
  unsigned long TopLineOrd;             /* ordinal in doc of top line in window     */
  HANDLE hLastSeenBlock;
  unsigned int LastSeenOffset;
  TypLineID LastSeenLineID;
  HANDLE hFindBlock;                    /* location of place to start next search   */
  unsigned int FindOffset;              /* for "SearchStr"                          */
  TypLineID FindLineID;
  unsigned int FindTextOffset;
  char SearchStr[MAXFINDSTRING];        /* Search string for current search    */
  unsigned int ScXOffset;               /* # of chars offset for horizontal scroll  */
  unsigned int ScXChars;                /* # of chars/line for current window size  */
  unsigned int ScYLines;                /* # of lines that fit in current window    */
  unsigned int ScXWidth;                /* current size of client area of window    */
  unsigned int ScYHeight;
  HWND hDocWnd;
  struct structdoc *ParentDoc;          /* pointer to parent document            */
  HANDLE hParentBlock;                  /* points to line in parent doc          */
  unsigned int ParentOffset;            /* that corresponds to/describes this    */
  TypLineID ParentLineID;               /* document                              */
  unsigned int OffsetToText;
  BOOL InUse;                           /* TRUE if this TypDoc in use.           */
  int DocType;                          /* DOCTYPE_xxx                           */
  BOOL TextSelected;                    /* Indicates text selected               */
  TextSelect BeginSelect;               /* Line and Char where selection began   */
  TextSelect EndSelect;                 /* Line and Char where selection ended   */
  HWND hWndTB;                          /* Handle of the toolbar child window  (jlg)  */
  HWND hWndFrame;                       /* Handle of the parent frame window     */
  HWND hWndXFace;
  HBITMAP hbmFace;
  char szStatBarText[MAXSTATBARTEXT];   /* status bar text string        */
  char szStatCommText[MAXSTATCOMMTEXT];
  int  StatBarPercent;                  /* 0 - 100 for thermometer in status bar */
  int  nStatBarCommPanel;
  TypLineID ActiveLineID;               /* Line ID of "active" line in multi-select list (jlg)  */
  TypLineID AnchorLineID;               /* Line ID of "anchor" line in multi-select list        */
  unsigned int SelectedLines;           /* num lines selected (jsc) */
  long KilledLines;
  int numArtsSaved;                     /* used when saving selected articles */
  int numArtsError;                     /* used when saving selected articles */
  int savingArtIndex;                   /* used when saving/decoding selected articles */
  int curSaveArtIndex;

  unsigned long NextTopLine;            /* > 0 if page feed by CTRL-L (shimomai) */
  unsigned char Flags;					// A place to store so flags, Thumbtracking, yEnc, Preview
  HFONT hFontArtQuote;
   //hWinVnFont = hCompositionFont = hListFont   
} ALIGNED TypDoc;

#define yEncoded '\x01'
#define BNewsEnc '\x02'
#define UUCoded  '\x04'
#define ThumbTracking '\x08'
#define InstantUpdate '\x10'
#define PreviewDecode '\x20'
#define EndOfArtViewed '\x40'


__inline void SetFlags(TypDoc* pDoc, unsigned char cFlag)
{ 
    if (pDoc)
        pDoc->Flags |= cFlag; 
};

__inline void ClearFlags(TypDoc* pDoc, unsigned char cFlag)
{ 
    if (pDoc)
        pDoc->Flags &= ~cFlag; 
};
__inline BOOL IsFlagSet( TypDoc* pDoc, unsigned char cFlag)
{

    if ( (pDoc && pDoc->Flags & cFlag) != 0)
        return TRUE;

    return FALSE;
};

typedef struct structblock {
  HANDLE hPrevBlock;                /* handle of previous block, or 0               */
  HANDLE hNextBlock;                /* handle of next block in document, or 0       */
  HANDLE hCurBlock;                 /* handle of this block                         */
  TypDoc *OwnerDoc;                 /* pointer to document this block is in.        */
  long LWAp1;                       /* # of used data bytes in block, inc header    */
  long NumLines;                    /* # of lines in this block                     */
  long NumActiveLines;              /* # of active lines in this block.             */
  int eob;                          /* end-of-block; must be just before 1st line.  */
  /* Text lines */
  /* Another EOB marker */
} ALIGNED TypBlock; /* IF YOU MODIFY THIS STRUCT MAKE SURE ITS NOT PADDED AT END SO PrevLine() WORKS */

typedef struct structline {
  int length;                                   /* Total # of bytes in line, all-inclusive    */
  TypLineID LineID;                             /* Unique identifier for this line.           */
  int active;                                   /* =1 if line should be displayed, else 0     */
  /* Bytes of text */
  /* Another copy of length */
} ALIGNED TypLine;

typedef struct structtext {
  int NameLen;                                  /* # of bytes of text                          */
} ALIGNED TypText;

typedef struct SendmeList {
   struct SendmeList * next;
   unsigned long article;
} ALIGNED TypSendmeList;

typedef struct structgroup {
  char Subscribed;        // =TRUE if subscribed to this group. 
  char Selected;          // =TRUE if selected 
  char Determined;        // =TRUE if group info has been retrieved
  char Threaded;          // =TRUE if has thread references 
  int NameLen;            // # of bytes in group name 
  TypDoc *SubjDoc;        // points to doc containing subjs
  UBIGINT ServerEstNum;   // est # of arts in server 
  UBIGINT ServerFirst;    // # of first art that server has.
  UBIGINT ServerLast;     // # of last art that server has.
  UBIGINT uLoadFirst;     // # of first art loaded from server
  UBIGINT uLoadLast;      // # of last art loaded from server
  UBIGINT HighestPrevSeen;// # of highest art server had in last session, from "s<num>" newsrc field  
  BIGINT NumUnread;      // num unseen arts (jsc)
  long alloc_headers;     // total # of headers allocated -this info lost whenever group doc total_header val changed. MDS 20001117 
  long total_headers;     // total # of active headers in array 
  long max_headers;       // killed & unkilled headers MDS
  char * Description;     // points to description 
  HANDLE header_handle;   // handle to global block of header array mem 
  HANDLE thread_handle;   // handle to global block of thread ind. pointers 
  void*  pFile_sort;
  WVArticleAction*	pAA;
  WVSeenDB*	pSeendb;
  WVAddHdr*	pAddHdr;
#ifdef OFFLINE
  TypSendmeList*pSME;
#endif
} ALIGNED TypGroup;

typedef struct structarticle {
  UBIGINT Number;                 /* Server's number for this article    */
  char Seen;                      /* =TRUE if article seen               */
  char Selected;                  /* =TRUE if article selected           */
  TypDoc *ArtDoc;                 /* points to doc with actual article   */
  int NameLen;                    /* # of bytes in subject line */
  /* Subject line of article */
} ALIGNED TypArticle;

#define HEADER_MESSAGE_ID_LENGTH 100

typedef long huge *thread_array;

typedef thread_array huge *thread_array_p;

typedef char huge *char_p;

typedef struct structrange {
  UBIGINT First;
  UBIGINT Last;
} ALIGNED TypRange;

/* TypMRRFile is used to describe a file; I use it because Windows */
/* doesn't provide much in the way of disk I/O support.  */

typedef struct structMRRfile {
#ifdef _WIN32
	HANDLE hFile;
#else
	HFILE hFile;                          /* handle to file                            */
#endif
	OFSTRUCT of;
	char buf[BUFSIZE];                    /* my I/O buffer.                            */
	int bufidx;                           /* Index to next place in buf                */
	int bytesread;                        /* for reads, # of bytes read in last read   */
	int mode;                             /* mode in which to open file.               */
	int eofflag;                          /* whether we have reached EOF (read)        */
} ALIGNED TypMRRFile;

#define CtoX(c) (c*CharWidth + SideSpace)
#define LtoY(l) (l*LineHeight + TopSpace)
#define EDITID   1                      /* ID of edit box, to identify for return values */
#define MAXMEMONAME 15                  /* Number of chars in memo name */
#define MEMONAMECHARS (MAXMEMONAME+2)
#define MAXVIEWS 10
#define END_OF_BLOCK (-1)
#define BLOCK_SIZE  4096



#define GetGroup(LinePtr) (TypGroup far *) (((char far *) LinePtr) + sizeof (TypLine))
#define GetGroupName(LinePtr) (char far *) (((char far *) LinePtr) + sizeof (TypLine) + sizeof (TypGroup))
#define GroupLenPtr(LinePtr) (*(int *) ((char *) LinePtr + LinePtr->length - sizeof (int)))
#define GetTextPtr(LinePtr) (char far *) ((char far *) (LinePtr) + sizeof (TypLine) + sizeof (TypText))
#define GetTextLen(LinePtr) ((TypText far *) ((char far *) (LinePtr) + sizeof (TypLine)))->NameLen

#ifdef WINMAIN
#define DEF
#else
#define DEF extern
#endif

DEF TypDoc NetDoc;

#define MRR_SCROLL_LINEUP    0
#define MRR_SCROLL_LINEDOWN  1
#define MRR_SCROLL_PAGEUP    2
#define MRR_SCROLL_PAGEDOWN  3


/* This structure maps between keystrokes and mouse events.
 * From an idea on p. 137 of Charles Petzold's book.
 * If you change the definition, be sure to update NUMKEYS.
 */
#define NUMKEYS 8
#ifndef MAC
DEF struct {
  WORD wVirtKey;
  int CtlState;
  int iMessage;
  WPARAM wRequest;
} ALIGNED key2scroll[NUMKEYS]

#ifdef WINMAIN
=
{
    VK_PRIOR, 0, WM_VSCROLL, SB_PAGEUP,
        VK_NEXT, 0, WM_VSCROLL, SB_PAGEDOWN,
        VK_UP, 0, WM_VSCROLL, SB_LINEUP,
        VK_DOWN, 0, WM_VSCROLL, SB_LINEDOWN,
        VK_LEFT, 0, WM_HSCROLL, SB_LINEUP,
        VK_RIGHT, 0, WM_HSCROLL, SB_LINEDOWN,
        VK_HOME, 0, WM_VSCROLL, SB_TOP,     //MDS 19981230 & NUMKEYS6->8
        VK_END, 0, WM_VSCROLL, SB_BOTTOM

}

#endif
;
#endif

DEF int Initializing;
DEF BOOL Reconnecting;
DEF BOOL Autoconnect;
#define INIT_DONE                0
#define INIT_READING_NEWSRC      1
#define INIT_ESTAB_CONN          2
#define INIT_SCANNING_NETDOC     3
#define INIT_GETTING_LIST        4
#define INIT_NOT_CONNECTED       5
#define INIT_READY               6

//#ifdef OFFLINE  // TANAKA Goh
//#define MAXGROUPWNDS   1
//#else
#ifdef _WIN32
#define MAXGROUPWNDS   16
#define MAXARTICLEWNDS 16
#else 
#define MAXGROUPWNDS   4
#define MAXARTICLEWNDS 4
#endif
#define MAXPOSTWNDS    4
#define MAXMAILWNDS    4

#ifdef MULTIGROUP
DEF TypDoc GroupDocs[MAXGROUPWNDS+1];
#else
DEF TypDoc GroupDocs[MAXGROUPWNDS];

#endif
DEF TypDoc ArticleDocs[MAXARTICLEWNDS];
#ifdef JAPANESE
DEF TypDoc ArticleRecord[MAXARTICLEWNDS];
#define GetArtRec(artdoc) (artdoc - ArticleDocs + ArticleRecord)
#endif
DEF int NumGroupWnds;
DEF int NumArticleWnds;

typedef enum eEncodingType 
{ CODE_NONE = 0, 
  CODE_BASE64, 
  CODE_UU, 
  CODE_XX, 
  CODE_YENC, 
  CODE_CUSTOM,
  CODE_QP,
  CODE_8BIT,
  CODE_7BIT,
  CODE_BINARY, 
  CODE_UNKNOWN 
 };

#define NUM_ENCODING_TYPES 6
DEF char *EncodingTypes[NUM_ENCODING_TYPES]
#ifdef WINMAIN
 = {"None", "Base-64", "UU", "XX", "yEnc", "Custom", }
#endif
;


typedef struct textBlockStruct {
  HWND hTextWnd;
  BOOL IsBusy;
  unsigned long numLines;
  unsigned long maxLines;
  unsigned long numBytes;
  unsigned long maxBytes;
  unsigned int maxLineLen;
  char huge *text;                              /* big text of all lines */
  unsigned long huge *offset;   /* array of offsets into text array */
} ALIGNED TypTextBlock;

typedef struct _attachmentStruct {
  char fileName[MAXFILENAME];
  char contentType[MAXCONTENTTYPELEN];
  eEncodingType  encodingType;
  eEncodingType  encodingSubType;
  char encodingTypeStr[16];
  unsigned long numBytes;               /* this is size of fileName */
  BOOL attachInNewArt;
  int  nAttachParts;		//for yEnc num parts
  int  nCurPart;
  int  nAttachBytes;		//for yEnc part size
  DWORD dwCRCPart;
  DWORD dwCRCFull;
} ALIGNED TypAttachment ;

typedef   TypAttachment * LPTypeAttachment;

#define HDR_NUM_CONTROLS 12
/* these are indexes into the UI control array */
#define HDR_TO                  0               /* has a browse button */
#define HDR_GROUPS              1
#define HDR_SUBJECT             2
#define HDR_FROM                3
#define HDR_ORG                 4
#define HDR_REPLYTO             5
#define HDR_CC                  6               /* has a browse button */
#define HDR_KEYWORDS            7
#define HDR_SUMMARY             8
#define HDR_DIST                9
#define HDR_FOLLOWTO            10
#define HDR_ATTACH              11


#define HDR_NUM_BUTTONS 2
/* these are indexes into the button control array */
#define BTN_TO                  0
#define BTN_CC                  1

typedef struct _HeaderControlStruct {
  HWND title[HDR_NUM_CONTROLS];
  HWND UI[HDR_NUM_CONTROLS];
  HWND button[HDR_NUM_BUTTONS];
  int yEdge;                                    /* y-coordinate of bottom of last control */
} ALIGNED TypHeaderControls;

DEF BOOL PrefillCcAddress;
DEF BOOL ShowFromHdr;
DEF BOOL ShowOrgHdr;
DEF BOOL ShowReplyToHdr;
DEF BOOL ShowKeywordsHdr;
DEF BOOL ShowSummaryHdr;
DEF BOOL ShowDistributionHdr;
DEF BOOL ShowFollowupToHdr;
DEF BOOL XNoArchive;
DEF BOOL UseCancelKey;
DEF BOOL NoXNewsreader;

#define MAX_NUM_ATTACHMENTS 250
typedef struct WndEditStruct {
  HWND hWnd;
  HWND hWndEdit;
  HWND ParenthWnd;          /* the parent window from which we post or mail */
  int composeType;          /* a doctype.  lets us tell if it's MAIL or FORWARD */
  char dirty;
  char busy;                /* TRUE if busy sending */
  char richedit;            /* true if richedit control */
  unsigned long bodyOffset; /* # bytes to skip in body for extra headers */
  TypDoc *Doc;
  TypHeaderControls *headerControls;
  TypAttachment *attachment[MAX_NUM_ATTACHMENTS];
  TypTextBlock *extraHeaders;
  HWND hLastFocusWnd;
  int numAttachments;
  int nextBatchIndex;        /* for batch post/mails */
  int nFixedWidth;
  BOOL bRestrictWidth;
} ALIGNED WndEdit;

#define DT_CLEAN 0
#define DT_DIRTY 1

DEF WndEdit WndPosts[MAXPOSTWNDS];
DEF WndEdit WndMails[MAXMAILWNDS];
DEF int NumPostWnds;
DEF int NumMailWnds;

#define DOCTYPE_UNKNOWN  0
#define DOCTYPE_NET      1
#define DOCTYPE_GROUP    2
#define DOCTYPE_ARTICLE  4
#define DOCTYPE_POSTING  8
#define DOCTYPE_MAIL     16
#define DOCTYPE_FORWARD  32
#define DOCTYPE_CANCEL   64
#define DOCTYPE_SUPERSEDE 128 

/* Temp buffer for trace info */
#ifdef _DEBUG
DEF char szDebugBuffer[1200];
#endif

typedef struct AutoDeleteStruct {
  HANDLE hProcess;
  char   szFile[MAX_PATH];
  struct AutoDeleteStruct* pNext;
} ALIGNED AutoDelete;

/* Variables and constants for handling the FSA used to deal with    */
/* talking to the NNTP server.                                       */

DEF int CommState;                      /* current state in comm FSA */
DEF BOOL CommBusy;                      /* =TRUE if comm line busy interacting w/ server */
DEF int  CommDecoding;                  /* =TRUE if comm line busy decoding lines from server */
DEF int AutoDecode;                     /* 1  if multiple group saving/decode */
DEF BOOL SendModeReader;
DEF BOOL AbortDownload;
DEF TypDoc *CommDoc;                    /* Document currently receiving lines from server   */
DEF TypGroup *InlineGroupPtr;				// Group Ptr used for inline group retrieval
DEF HWND hVerDlgList;                   /* Handle to info in the Version Dialog Box */

DEF char CommLineIn[MAXCOMMLINE];       /* current input line being built by FSA   */
DEF char *CommLinePtr;                  /* pointer to next place to put char in CommLineIn  */
DEF char *CommLineLWAp1;                /* if we get this far, we're at end of buffer       */
DEF char IgnoreCommCh;                  /* char to ignore when reading from server          */
DEF char EOLCommCh;                     /* char that indicates end of line upon input       */
DEF TypDoc *ActiveGroupDoc;
#ifdef MULTIGROUP
DEF TypDoc *MultiGroupDoc;				// used to allow us to view groupless articles
#endif
DEF TypDoc *ActiveArticleDoc;
DEF WndEdit *ComposeWnd;                /* active compose window */
DEF AutoDelete *AutoDeleteList;         /* temp files to monitor to delete when not accessed */

DEF BOOL SendingMail, SendingPost;

#define MAXGROUPNAME 120
#define MAXDESCRIPTION 120
#define MAXARTICLEIDLEN 254
DEF char CurrentGroup[MAXGROUPNAME];    /* name of group currently selected on server */
DEF char CurrentDescription[MAXDESCRIPTION]; /* this is the Description for this group */
DEF char CurrentArticleID[MAXARTICLEIDLEN];
               /* taken by LIST NEWSGROUPS <group> command */

DEF int iSortOption;                    /* Article sorting option */

DEF BOOL threadp;
DEF BOOL xoverp;

DEF TypTextBlock* DebugText // S.Yoshida  (moved here MDS)
#ifdef WINMAIN
 = NULL; 
#endif
 ;


#define HDR_XHDR    1                   /* Use XHDR to talk to news server */
#define HDR_XOVER   2                   /* Use XOVER to talk to news server */
#define HDR_XZVER   3                   // Use XZVER
#define HDR_XZHDR   4                   // Use ZHDR 
#define HDR_AUTO    0                   /* Try XOVER and if fails use XHDR */
DEF unsigned int force_xhdr;
DEF unsigned int use_zhdr
#ifdef WINMAIN
 = 1;
#endif
 ;
DEF unsigned int ip_family
#ifdef WINMAIN
 = 0;
#endif
 ;
DEF BOOL g_bUseXHDR                     /* Use HEAD when 0, 'cause XHDR doesn't work */
#ifdef WINMAIN
 = 1;
#endif
 ;

#define MAXNNTPSIZE 120
#define MAXHOSTNAMESIZE 255
#define MAXPREFIXSIZE 40
#define MAXTZONESIZE 60
DEF char NNTPHost[MAXNNTPSIZE];
DEF char NNTPService[MAXNNTPSIZE];
DEF char SMTPService[MAXNNTPSIZE];
DEF char SMTPHost[MAXNNTPSIZE];
DEF char NNTPUserName[MAXNNTPSIZE];
DEF char SMTPUserName[MAXNNTPSIZE];
DEF char NNTPPasswordEncrypted[2 * MAXNNTPSIZE];
DEF char SMTPPasswordEncrypted[2 * MAXNNTPSIZE];
DEF char TimeZone[MAXTZONESIZE];
DEF char MAPIPrefix[MAXPREFIXSIZE];
DEF BOOL NNTPSavePassword;
DEF BOOL SMTPSavePassword;
DEF BOOL AuthReqPost;                   /* TRUE if we may not post at all unless authenticated */
DEF BOOL AuthReqMail;                   /* TRUE if we may not send mail unless authenticated */
DEF BOOL Authenticated                  /* TRUE if we've been authenticated by NNTP server */
#ifdef WINMAIN
= FALSE
#endif
 ;
DEF unsigned int NntpdBugWait;         /* = 0 if server isn't buggy, else about 300 */

DEF BOOL GetNewsgroupsViaNNTP;         /* TRUE if we emulate XHDR newsgroups n1-n2 with HEAD n1 ... */

/* This is the name that was successfully authenticated by the NNTP server.
 * It might not be the same as NNTPUserName, if the user has changed the
 * username since the beginning of the session.
 */
DEF char AuthenticatedName[MAXNNTPSIZE];

#define MAILLEN 256
DEF char MailAddress[MAILLEN];
DEF char ReplyTo[MAILLEN];
DEF char UserName[MAILLEN];
DEF char Organization[MAILLEN];
DEF char MyOwnHost[MAXHOSTNAMESIZE]; /* my own hostname taken from *.ini or faked */
                                  /* to create unique Msg-Id's in some cases */

DEF char GenSockDLL[MAXFILENAME];
DEF int ConnectAtStartup;
DEF int UseSSL
#ifdef WINMAIN
= 0
#endif
;
DEF int SMTPUseSSL
#ifdef WINMAIN
= 0
#endif
;

DEF int SMTPIP_Family
#ifdef WINMAIN
= 0
#endif
;

DEF BOOL EnableGroupFilter;
DEF char *GroupFilter
#ifdef WINMAIN
= 0
#endif
;

/* moved state defns to a separate include file to associate stringtable (jlg) */
#include "wvstates.h"

#define LFN_HELP "WINVN.HLP"
#define LFN_HTMLHELP "WinVN.chm"

/* variables used in an ad hoc attempt to optimize updating of windows
 * by the input cracking FSA. */

#define UPDATE_TITLE_FREQ       10
#define UPDATE_ART_FREQ         12
#define MAX_IMMEDIATE_UPDATE    2
#define STATUS_UPDATE_FREQ      20

//DEF unsigned int RcvLineCount;
DEF long RcvLineCount;

DEF TypLineID NextLineID                /* LineID to assign to next created line */
#ifdef WINMAIN
= 10664L
#endif
 ;

DEF HINSTANCE hInst;
DEF HWND hWndConf;
DEF HACCEL hAccel;           /* handle to main accelerator table */
DEF MSG MainMsg;             /* message returned from GetMessage */
DEF UINT uRegMsg;			//registered windows message ID

DEF char str[MAXHEADERLINE];    /* general-purpose string buffer */


DEF HCURSOR hSaveCursor;                /* handle to current cursor      */
DEF HCURSOR hHourGlass;                 /* handle to hourglass cursor    */


//DEF int X, Y;         /* last cursor position          */
DEF int DragMouseAction;                /* mouse action for dragging      */

#define DRAG_NONE                  0
#define DRAG_SELECT                1
#define DRAG_DESELECT              2
#define SEEN_SELECT                3
#define SEEN_DESELECT              4

DEF POINT ptCursor;                             /* x and y coordinates of cursor */
DEF POINT ptXFaceCoord                          // coordinates or XFACE relative to ArtWnd
#ifdef WINMAIN
= { 0, 200}
#endif
 ;


DEF int ViewNew;
DEF int NewArticleWindow;
DEF int SelectAll;
DEF int DoList;
DEF int did_list;
DEF unsigned long article_threshold;
DEF unsigned long min_to_retrieve;
DEF UBIGINT est_num_unread;
DEF UBIGINT arts_to_retrieve;
/* Ray Dunn:99/10: Dont like using a global, but the others are too, so: */
DEF UBIGINT arts_reqd_for_first_unseen;
DEF UBIGINT art_num;
DEF UBIGINT server_first;
DEF UBIGINT server_last;
/* Ray Dunn:99/10:End */
DEF unsigned long MaxDBSize;


DEF BOOL FullNameFrom;
DEF BOOL TrimHeaders;
DEF BOOL ScrollPastHeaders;
/* Ray Dunn:99/10 */
DEF BOOL ShowAuthorName;
/* Ray Dunn:99/10:End */
DEF BOOL ShowXFace;
DEF BOOL RMDeselectOnMark;
DEF BOOL ItalicizeQuotes;
DEF BOOL WrapIncomingArticleText;
DEF int WrapIncomingArticleTextLength;
DEF BOOL WordWrap;
DEF BOOL ConfirmBatchOps;
DEF BOOL ConfirmSaveOnExit;
DEF BOOL ConfirmExitActive;
/* Ray Dunn:99/10 */
DEF BOOL ConfirmXPosting;
/* Ray Dunn:99/10:End */
DEF BOOL ConfirmReplyTo;
DEF BOOL ConfirmDisconnect;
#ifdef OFFLINE  // TANAKA Goh
DEF BOOL ConfirmDeleteArticle;
#endif
DEF BOOL ShowUnsubscribed;
DEF BOOL SortGroupList;
//DEF BOOL ShowReadArticles;
DEF BOOL ShowUnreadOnly;
DEF BOOL SaveNewsrc;
DEF BOOL NewsrcDirty;
DEF BOOL SaveConfig;
DEF BOOL ShowDescription;
DEF BOOL ShowUnreadCount;
DEF BOOL bEnableArticleAction;
DEF BOOL g_bIsXP;
DEF BOOL g_bIsVista;
DEF BOOL g_bHaveGroupsHeader;
DEF BOOL bClearSelections;
/* Ray Dunn:99/10 & 99/11*/
DEF BOOL SortWithAlphaOnly;
DEF BOOL InhibitSort;
/* Ray Dunn:99/10:End */
DEF char LastArticleTextFind[MAXFINDSTRING];
DEF char LastArticleHeaderFind[MAXFINDSTRING];
DEF char LastGroupNameFind[MAXFINDSTRING];
DEF char LastMIDFind[MAXFINDSTRING];

#define THREAD_COMPLETE    1
#define THREAD_INCOMPLETE  2


DEF BOOL ArticleFixedFont;

DEF int xScreen, yScreen;
DEF int CaptionHeight;
DEF HFONT hWinVnFont;                   /* handle to font for WinVN status bar/etc */
DEF HFONT hCompositionFont;             /* handle to font for Composition body text */
DEF HFONT hListFont;                    /* handle to font used in group/art lists */
DEF HFONT hFontArtNormal;               /* handle to font used in Article window - normal
                                                                   text mode. */
DEF HFONT hFontArtQuote;                /* handle to font used in Article window - 
                                                                   comments == Italics. */
DEF HFONT hFontPrint;                   /* handle to font used for printing. */
DEF HFONT hFontPrintB;                  /* handle to font used for bold printing. */
DEF HFONT hFontPrintS;                  /* handle to font used for printing Subject line. */
DEF HFONT hFontPrintI;                  /* handle to font used for printing Quoted lines. */
DEF HFONT hStatusFont;                  /* handle to font used in status windows */

#define FONT_MASK_SYSTEM	0x01
#define FONT_MASK_COMPOSITION 0x02
#define FONT_MASK_LIST		0x04
#define FONT_MASK_ART		0x08
#define FONT_MASK_STATUS	0x10
#define FONT_MASK_PRINT		0x20
DEF int WinVNFontChange;
DEF int UseClearType;

DEF int WinVnFontSize;
DEF char WinVnFontFace[32];
DEF char WinVnFontStyle[32];
DEF int WinVnLineHeight, WinVnCharWidth;        /* # of windows units for WinVn font */

DEF int CompositionFontSize;
DEF char CompositionFontFace[32];
DEF char CompositionFontStyle[32];
DEF int CompositionLineHeight, CompositionCharWidth;

DEF int ListFontSize;
DEF char ListFontFace[32];
DEF char ListFontStyle[32];
DEF int LineHeight, CharWidth;  /* # of window units for list font */
DEF int TopSpace, SideSpace;    /* # of window units to leave at top and side  */
                                /* of window (for aesthetic purposes)          */

DEF int ArticleFontSize;
DEF char ArticleFontFace[32];
DEF char ArticleFontStyle[32];
DEF unsigned int ArtLineHeight, ArtCharWidth;   /* # of windows units for article font */
DEF unsigned int ArtTopSpace, ArtSideSpace;     /* # of window units to leave at top and side  */

DEF int PrintFontSize;
DEF char PrintFontFace[32];

DEF int StatusFontSize;
DEF char StatusFontFace[32];
DEF char StatusFontStyle[32];
DEF int StatusLineHeight, StatusCharWidth;      /* # of window units for status font */

DEF int StartPen;                               /* Similar to TopSpace; where to start pen 1st row */
DEF int ScreenYPixels;                  /* used in converting points to logical units */
DEF int PrinterYPixels;                 /* used in converting points to logical units */
DEF COLORREF OldTextColor, OldBkColor;
DEF COLORREF NetUnSubscribedColor;      /* color to use for unsubscribed groups  */
DEF COLORREF NetSubscribedColor;        /* color to use for subscribed groups  */
DEF COLORREF ArticleSeenColor;  /* color to use for articles that have been seen */
DEF COLORREF ArticleKilledColor;        /* color for unseen articles that have been marked seen */
DEF COLORREF ArticleUnSeenColor;        /* color to use for articles that have not been seen */
DEF COLORREF ArticleTextColor;  /* color to use for article/post text */
DEF COLORREF StatusTextColor;   /* Color to use for status text */
DEF COLORREF ListBackgroundColor;       /* background color for group/article listings */
DEF COLORREF ArticleBackgroundColor;    /* background color for article/post windows */
DEF COLORREF StatusBackgroundColor;             /* background color for status windows */
DEF COLORREF CustomColors[16];  /* Custom colors definable by user in ChooseColor */
DEF COLORREF ArticleErrorColor;         /* color to use for articles not available on server */
DEF COLORREF ArticlePreviewColor;       /* color to use for articles selected for preview */
DEF HBRUSH hListBackgroundBrush;
DEF HBRUSH hArticleBackgroundBrush;
DEF HBRUSH hStatusBackgroundBrush;
DEF BOOL LimitedColor;
DEF BOOL UseInverseSelections;
DEF BOOL ShowSplashScreen;

DEF int ReverseVideo;
DEF BOOL ThumbTrack;

DEF BOOL MailDemandLogon;               /* FALSE = permanent logon
                                                                   TRUE  = logon on send mail */
DEF int MailForceType;                  /*  Force Mail Type to valid value where
                                                                   Less then zero means
                                                                   default negotiation */
DEF int MailLog;                                /* True means append to log files */
DEF int PostLog;                                /* where XXXXLogFile is file name */
DEF int MailLogAttach;                          /* True means to log mail attachments */
DEF int PostLogAttach;                          /* True means to log post attachments */

DEF char MailLogFile[MAXFILENAME];
DEF char PostLogFile[MAXFILENAME];

DEF int fmtDaysB4Mth;
DEF char fmtDateDelim[2];


#define QuoteLineInd  '>'
#define ExternLineInd ':'
#ifdef WANTOLDACTION
DEF DLGPROC lpfnWinVnArticleActionDlg;
#endif
DEF DLGPROC lpfnWinVnArticleAction;
DEF DLGPROC lpfnWinVnSaveArtDlg;
DEF DLGPROC lpfnWinVnSaveArtsDlg;
DEF DLGPROC lpfnWinVnFindDlg;
DEF DLGPROC lpfnWinVnGenericDlg;
DEF DLGPROC lpfnWinVnSubjectDlg;
DEF DLGPROC lpfnWinVnCommDlg;
DEF DLGPROC lpfnWinVnAuthDlg;
DEF DLGPROC lpfnWinVnDoListDlg;
DEF DLGPROC lpfnWinVnPersonalInfoDlg;
DEF DLGPROC lpfnWinVnExecuteInfoDlg;
DEF DLGPROC lpfnWinVnConfirmationDlg;
DEF DLGPROC lpfnWinVnAppearanceDlg;
DEF DLGPROC lpfnWinVnControlSubclass;
DEF DLGPROC lpfnWinVnThresholdDlg;
DEF DLGPROC lpfnWinVnLogOptDlg;
DEF DLGPROC lpfnWinVnDecodeArtsDlg;
DEF DLGPROC lpfnWinVnAttachDlg;
DEF DLGPROC lpfnWinVnComposePrefsDlg;
DEF DLGPROC lpfnWinVnAttachPrefsDlg;
DEF DLGPROC lpfnWinVnEncodeDlg;
DEF DLGPROC lpfnWinVnExitDlg;
DEF DLGPROC lpfnWinVnMailDlg;
DEF DLGPROC lpfnWinVnSmartFilerDlg;
DEF DLGPROC lpfnWinVnSelectPathDlg;
DEF DLGPROC lpfnWinVnArticleDlg;
DEF DLGPROC lpfnWinVnCodingPrefsDlg;
DEF DLGPROC lpfnWinVnArtListDlg;
DEF DLGPROC lpfnWinVnGroupListDlg;
DEF DLGPROC lpfnWinVnHeadersDlg;        // shimomai
DEF DLGPROC lpfnWinVnSMTPDlg;
DEF DLGPROC lpfnWinVnMergeDlg;
DEF DLGPROC lpfnWinVnAppendDlg;


DEF char *szAppName;
DEF char szAppProFile[MAXFILENAME];
DEF char szNewsSrc[MAXFILENAME];
DEF FILETIME ftNewsSrc;

DEF char SaveArtFileName[MAXFILENAME];
DEF char DecodePathName[MAXFILENAME];
DEF char DialogString[MAXDIALOGSTRING];
DEF char AddressString[MAXDIALOGSTRING];
DEF char NameString[MAXDIALOGSTRING];
DEF char CcAddress[MAXDIALOGSTRING];
DEF char AttachPath[MAXFILENAME];
DEF BOOL CcByMail;
DEF int SaveArtAppend;
DEF BOOL SaveNewsrcOnClose;
DEF int ThreadFullSubject;
DEF char ThreadDepthIndicator[2];
DEF BOOL GroupListMultiSelect;
DEF BOOL ArtListMultiSelect;
DEF BOOL TrackSubscribedCrossposts;
DEF BOOL TrackUnsubscribedCrossposts;

DEF TypDoc *FindDoc;
DEF char *NewsgroupsPtr;                /* Used to pass pointer to newsgroup of new posting. */

/* For each new group detected, we create an entry in the following
 * array, NewGroupTable.  Each entry contains a far pointer to a
 * dynamically-allocated global data structure containing a line
 * containing information on this group, in the exact same format
 * as used in the NetDoc.
 */
DEF void huge *huge * NewGroupTable;    /* array of pointers to new group lines */
DEF HANDLE hNewGroupTable;              /* Handle to the above array */
DEF unsigned long nNewGroups;
DEF HANDLE hNewGroupData;
DEF void huge *NewGroupData;
DEF unsigned long HashTableSize;
DEF unsigned long LinesInRC;

typedef struct structHier {
  HANDLE hName;
  long Start;
  unsigned long NumGroups;
  HANDLE hNext;
} ALIGNED TypHier;

#define ADD_SUBSCRIBED_END_OF_SUB       0
#define ADD_SUBSCRIBED_TOP_OF_DOC       1
#define ADD_FIRST_SELECTED              2

#define LINE_FLAG_SET                   0

#define GROUP_ACTION_SUBSCRIBE          0
#define GROUP_ACTION_UNSUBSCRIBE        1
#define GROUP_ACTION_CHECK_ACTIVE       2
#define GROUP_ACTION_GET_GROUPNAMES 3
#define GROUP_ACTION_SELECTED       4   
#define GROUP_ACTION_CATCHUP        5
#define GROUP_ACTION_UNREAD         6
#define GROUP_ACTION_DELETESELECTED 7

#define ARTICLE_ACTION_SAVE             0
#define ADDSELECT                       3
#define EXTEND                          2
#define COMPARE                         1
#define NO_COMPARE                      0
#define SHOW                            1
#define NO_SHOW                         0
#define NO_ID                           NULL
#define REUSE                           1
#define NO_REUSE                        0
#define SELECT                          1
#define DESELECT                        0
#define INVERT							2
#define SELKILLED                       4
#define ENABLE                          1
#define DISABLE                         0
#define BLOCK_ACTION_SET_ACTIVE         0

DEF int il, ic;
DEF int irow;
DEF int imemo;
DEF int ih;

#if 0
#define MAXCOMMSPEEDCHARS 7
DEF int CommPortID;                             /* IDD_COM1 or IDD_COM2 */
DEF int CommParityID;                   /* IDD_7EVEN or IDD_8NONE  */
DEF char pszCommSpeed[MAXCOMMSPEEDCHARS];       /* character version of comm speed */
#endif

DEF UINT_PTR idTimer;                                /* timer ID            */
DEF UINT_PTR AppCheckId;

//#define IncPtr(ptr,byint) (char far *) ptr += byint

/* the MailCtrl global variable is scoped globally after the main window is
   created and is only modified at creation during MailInit in wvmail.c */
DEF struct MailCtrlStruct {
  int MailType;
  int enableMail;
  int enableLogout;
  int enableForward;
  int (*fnMlInit) (HWND hWnd);
  int (*fnMlLogout) (HWND hWnd);
  int (*fnMlClose) (HWND hWnd);
  int (*fnMlWinCreate) (HWND hWnd, TypDoc * Doc, int DocType);
} ALIGNED MailCtrl;

#define MT_NONE 0
#define MT_MAPI 1
#define MT_SMTP 2

#define INACTIVE                0       /* values for CodingState      */
#define DECODE_ACTIVE           1       /* values for Decoding must be */
#define DECODE_SKIPPING         2       /* a contiguous range          */
#define DECODE_PROCESSING       3
#define DECODE_GET_TABLE        4
#define DECODE_YENC_HEADER      5
#define ATTACH_PROCESSING       10      /* Encodes must be > decodes   */
#define ATTACH_SENDING          11
#define ATTACH_READFILE         12
#define ATTACH_WAITING          13

#define MIMEINIT                0
#define MIMETRANSFER            1
#define MIMETYPE                2
#define MIMEDESC                3

#define APPLEFILE               1
#define TEXTFILE                2
#define HTMLFILE                3
#define IMAGEFILE               4
#define AUDIOFILE               5
#define VIDEOFILE               6
#define APP_FILE                7


#define CODINGTABLESIZE         64
#define CODINGMAPSIZE           256

#define BASE_BLOCK_SIZE         16384   /* base size for the huge data */
typedef struct structcoded {
  char name[MAXFILENAME];               /* original file name from begin line */
  char ident[MAXINTERNALLINE];          /* based on article subject line + author */
  char MimeID[MAXINTERNALLINE];         /* actual mime ID from multipart message */ //MDS 20000411
  BOOL bMime;                           /* TRUE if MimeID can be valid */
  BOOL beginFlag;                       /* =TRUE this block is begin of the complete binary */
  BOOL endFlag;                         /* =TRUE this block is end of the complete binary */
  BOOL bsubjWrap;                       /* =TRUE when parsing subject: line */
  int  nMimeState;                      /* when decoding mime header */
  int  nAppType;                        /* apple etc.*/
  int sequence;                         /* =-1 if unknown, or # in mult-part file */
  int nTotal;                           /* =-1 if unknown, or expected # in mult-part file */
  int seqConfidence;                    /* confidence of sequence info */
  long estNumLines;                     /* info obtained from Lines: header during decode */
  unsigned long numLines;               /* num lines read so far (for status window */
  unsigned long numBytes;               /* # of bytes used in this coded data block */
  unsigned long maxBytes;               /* max # of bytes in this coded data block */
  char huge *data;                      /* the huge data array */
  HWND hParentWnd;                      /* handle to group wnd that started this */
  DWORD dwCRC;                          /* CRC for yEnc */
  DWORD dwCRCExpected;                  /* Expected CRC for yEnc part */
  DWORD dwExpectedBytes;                /* yEnc size */
  DWORD dwPartSize;                     /* yEnc part actual bytes */
} ALIGNED TypCoded;

#define MAX_DECODE_BLOCKS  256  /* max # of parts for a decode file */
#define MAX_DECODE_THREADS 75   /* max # of files in one batch decode */
typedef struct decodeThreadStruct {
  char name[MAXFILENAME];               /* original file name from begin line */
  char ident[MAXINTERNALLINE];          /* thread ID based on article subject line */
  char dosFileName[MAXFILENAME*2];        /* workable DOS file name */
  char contentType[MAXINTERNALLINE];    /* MIME content type */
  char contentDesc[80];                 /* MIME content description */
  char customTable[CODINGMAPSIZE];      /* custom coding table (if CODE_CUSTOM) */
  int contentEncoding;                  /* MIME content-transfer-encoding */
  int numBlocksWritten;                 /* number of blocks written to disk, so far */
  int mode;                             /* 2nd field of begin header, don't use in DOS */
  int numBlocks;                        /* number of coded blocks used in list */
  int expectedNumBlocks;                /* 0 if unknown, or a # if found in headers */
  unsigned long totalBytes;             /* total # of bytes for entire file */
  BOOL bMime;                           /* TRUE if MimeID can be valid */
  BOOL bStart;                          /* TRUE if we've written the first block */
  BOOL previewFlag;						// TRUE when extracting to temp path
  TypCoded *codedBlockList[MAX_DECODE_BLOCKS];  /* list of ptrs to decode objects */
  TypTextBlock *statusText;             /* buffers for thread status text window */
  HANDLE hProcess;
  BOOL bMonitor;
} ALIGNED TypDecodeThread;


#define ENCODE_LINE_LEN  45
#define YENCODE_LINE_LEN 128

#define END_BLOCK      2


#define NUM_CONTENT_TYPES 25



//type of data
enum eDataType { NONE=0,JPEG,ZIP, GIF, WAV, AVI, BMP, DOC, 
                 MID, EXE, HLP, PS,  AU,  VOC, AIF, MPEG,
                 LHA, ZOO, PNG, MOV, TIF, RTF, TXT, HTML,
                 HQX, SIT, SH,  TAR, GTAR,  Z,  GZ,  OCT, 
                 APP, IMG, ARJ,VIDEO,AUDIO,SND, RA,  RAR, 
                 PCX, WRI, PIC, MS,  PDF,MAPI, MP3,  PSD, 
                 JAR, ACE, IFF, VQF, WMF, PRZ,  RM, ASID,
				 WMV, WMA, XIF, Z7, APLE, OGG, ASF, PAR2, 
				 SWF, MAXDATATYPE };

// A structure to hold the datatype /extension/alternate extension/MIME type associations
typedef struct tagTypes
{
	eDataType type;
	char * szName;
	char * szExt;
	char * szAlt;
	char * szMIMEType;

} FILETYPES;

//Names of data
enum eNameType { IMAGE = 0, ARCHIVE, SOUND, AVFILE, DOCUMENT, EXECUTABLE, WEB, DATAFILE, MAXNAMETYPE };

//Mime types
enum eMIMEType { APPCOMP = 0, APPWORD, APPOCT, APPPDF, APPPS, APPRTF, APPGZ, APPSWF, APPZIP, AUDBAS, AUDMID, AUDMPG,
                 AUDWAV, IMGBMP, IMGGIF, IMGJPG, IMGPNG, IMGTIF, TXTHTM, TXTTXT, VIDMPG, VIDQT, VIDASF, VIDMS,
				 MIMEOTHER, MAXMIMETYPE };

//list of extension strings matching eDataType
DEF char * Extension[MAXDATATYPE] 
#ifdef WINMAIN
= {
    "---", "jpg", "zip", "gif", "wav", "avi", "bmp", "doc", 
    "mid", "exe", "hlp", "ps",  "au",  "voc", "aif", "mpg", 
    "lha", "zoo", "png", "mov", "tif", "rtf", "txt", "htm", 
    "hqx", "sit", "sh",  "tar", "tgz", "z",   "gz",  "oct", 
    "app", "img", "arj", "vid", "aud", "snd", "ra",  "rar",
    "pcx", "wri", "pic", "MSapp","pdf","mapi","mp3", "psd",
    "jar", "ace", "iff", "vqf", "wmf", "prz", "ram", "sid",
	"wmv", "wma", "xif", "7z",  "apl", "ogg", "asf", "par2",
	"swf"  }
#endif
;

//list of data names
DEF char* szDataNames[MAXNAMETYPE]
#ifdef WINMAIN
 = {
"image file", "archive file", "audio file", "AV file","document", "executable", "web document", "data file" }
#endif
;

//list of MIME types
DEF char *ContentTypes[MAXMIMETYPE]
#ifdef WINMAIN
 = {
 "application/x-compress",
 "application/msword",
 "application/octet-stream",
 "application/pdf",
 "application/postscript",
 "application/rtf",
 "application/x-gzip",
 "application/x-shockwave-flash",
 "application/zip",
 "audio/basic",
 "audio/midi",
 "audio/mpeg",
 "audio/x-wav",
 "image/bmp",
 "image/gif",
 "image/jpeg",
 "image/png",
 "image/tiff",
 "text/html",
 "text/plain",
 "video/mpeg",
 "video/quicktime",
 "video/x-ms-asf",
 "video/x-msvideo",
 "Other"}
#endif
;


//array of datatype /extension/alternate extension/MIME type associations
DEF  FILETYPES kFileTypes[] 
#ifdef WINMAIN
 ={
	{ BMP, szDataNames[IMAGE], Extension[BMP], NULL, ContentTypes[IMGBMP] },
	{ GIF, szDataNames[IMAGE], Extension[GIF], NULL, ContentTypes[IMGGIF] },
	{ IMG, szDataNames[IMAGE], Extension[IMG], NULL, ContentTypes[APPOCT] },
	{ JPEG,szDataNames[IMAGE], Extension[JPEG],"JPEG", ContentTypes[IMGJPG] },
	{ PCX, szDataNames[IMAGE], Extension[PCX], NULL, ContentTypes[APPOCT] },
	{ PIC, szDataNames[IMAGE], Extension[PIC], NULL, ContentTypes[APPOCT] },
	{ PNG, szDataNames[IMAGE], Extension[PNG], NULL, ContentTypes[IMGPNG] },
	{ PS,  szDataNames[IMAGE], Extension[PS],  NULL, ContentTypes[APPPS]  },
	{ PSD, szDataNames[IMAGE], Extension[PSD], NULL, ContentTypes[APPOCT] },
	{ TIF, szDataNames[IMAGE], Extension[TIF], "TIFF", ContentTypes[IMGTIF] },
	{ WMF, szDataNames[IMAGE], Extension[WMF], NULL, ContentTypes[APPOCT] },
	{ XIF, szDataNames[IMAGE], Extension[XIF], NULL, ContentTypes[APPOCT] },
	{ AIF, szDataNames[SOUND], Extension[AIF], NULL, ContentTypes[APPOCT] },
	{ ASID,szDataNames[SOUND], Extension[ASID],NULL, ContentTypes[APPOCT] },
	{ AU,  szDataNames[SOUND], Extension[AU],  NULL, ContentTypes[AUDBAS] },
	{ MID, szDataNames[SOUND], Extension[MID], NULL, ContentTypes[AUDMID] },
	{ MP3, szDataNames[SOUND], Extension[MP3], NULL, ContentTypes[AUDMPG] },
	{ OCT, szDataNames[SOUND], Extension[OCT], NULL, ContentTypes[APPOCT] },
	{ OGG, szDataNames[SOUND], Extension[OGG], NULL, ContentTypes[APPOCT] },
	{ RA,  szDataNames[SOUND], Extension[RA],  NULL, ContentTypes[APPOCT] },
	{ VOC, szDataNames[SOUND], Extension[VOC], NULL, ContentTypes[APPOCT] },
	{ VQF, szDataNames[SOUND], Extension[VQF], NULL, ContentTypes[APPOCT] },
	{ WAV, szDataNames[SOUND], Extension[WAV], NULL, ContentTypes[AUDWAV] },
	{ WMA, szDataNames[SOUND], Extension[WMA], NULL, ContentTypes[APPOCT] },

	{ ASF, szDataNames[AVFILE], Extension[ASF], "WMA, WMV", ContentTypes[VIDASF]},
	{ AVI, szDataNames[AVFILE], Extension[AVI], NULL, ContentTypes[VIDMS] },
	{ MOV, szDataNames[AVFILE], Extension[MOV], NULL, ContentTypes[VIDQT] },
	{ MPEG,szDataNames[AVFILE], Extension[MPEG], "MPEG", ContentTypes[VIDMPG] },
	{ RM,  szDataNames[AVFILE], Extension[RM], NULL, ContentTypes[APPOCT] },
	{ WMV, szDataNames[AVFILE], Extension[WMV], NULL, ContentTypes[APPOCT] },
	{ IFF, szDataNames[AVFILE], Extension[IFF], NULL, ContentTypes[APPOCT] },
	{ SWF, szDataNames[AVFILE], Extension[SWF], NULL, ContentTypes[APPSWF] },
	{ DOC, szDataNames[DOCUMENT], Extension[DOC], "PPT, XLS, DB", ContentTypes[APPWORD] },
	{ HLP, szDataNames[DOCUMENT], Extension[HLP], NULL, ContentTypes[APPOCT] },
	{ PDF, szDataNames[DOCUMENT], Extension[PDF], NULL, ContentTypes[APPPDF] },
	{ PRZ, szDataNames[DOCUMENT], Extension[PRZ], NULL, ContentTypes[APPOCT] },
	{ RTF, szDataNames[DOCUMENT], Extension[RTF], NULL, ContentTypes[APPRTF] },
	{ WRI, szDataNames[DOCUMENT], Extension[WRI], NULL, ContentTypes[APPOCT] },
	{ TXT, szDataNames[DOCUMENT], Extension[TXT], "INI, LOG, BAT, NFO", ContentTypes[TXTTXT] },
	{ PAR2, szDataNames[DATAFILE], Extension[PAR2], NULL, ContentTypes[APPOCT] },
	
	{ EXE, szDataNames[EXECUTABLE], Extension[EXE], "DLL, COM, VXD, SCR, DRV", ContentTypes[APPOCT] },
	{ SH,  szDataNames[EXECUTABLE], Extension[SH], NULL, ContentTypes[APPOCT] },
	{ HTML,szDataNames[WEB],		Extension[WEB], NULL, ContentTypes[TXTHTM] },
	{ ACE, szDataNames[ARCHIVE], Extension[ACE], "AC#", ContentTypes[APPOCT] },
	{ ARJ, szDataNames[ARCHIVE], Extension[ARJ], "A##", ContentTypes[APPOCT] },
	{ GZ,  szDataNames[ARCHIVE], Extension[GZ], NULL, ContentTypes[APPOCT] },
	{ HQX, szDataNames[ARCHIVE], Extension[HQX], NULL, ContentTypes[APPOCT] },
	{ JAR, szDataNames[ARCHIVE], Extension[JAR], "J##", ContentTypes[APPOCT] },
	{ LHA, szDataNames[ARCHIVE], Extension[LHA], NULL, ContentTypes[APPOCT] },
	{ RAR, szDataNames[ARCHIVE], Extension[RAR], "R##, S##", ContentTypes[APPOCT] },
	{ SIT, szDataNames[ARCHIVE], Extension[SIT], NULL, ContentTypes[APPOCT] },
	{ TAR, szDataNames[ARCHIVE], Extension[TAR], NULL, ContentTypes[APPOCT] },
	{ Z,   szDataNames[ARCHIVE], Extension[Z], NULL, ContentTypes[APPGZ] },
	{ ZIP, szDataNames[ARCHIVE], Extension[ZIP], NULL, ContentTypes[APPZIP] },
	{ Z7,  szDataNames[ARCHIVE], Extension[Z7], NULL, ContentTypes[APPOCT] },
	{ ZOO, szDataNames[ARCHIVE], Extension[ZOO], NULL, ContentTypes[APPOCT] },
	//"XLSX, DOCX, PPTX"

}
#endif
;
DEF int NUMFILETYPES
#ifdef WINMAIN
= sizeof(kFileTypes)/sizeof(kFileTypes[0])
#endif
;

/* coding and attachment globals  */
/* use 256 for arrays to support 2-byte charsets from Japan and Russia */
DEF char xxMap[CODINGMAPSIZE], uuMap[CODINGMAPSIZE], base64Map[CODINGMAPSIZE], customMap[CODINGMAPSIZE];
DEF char *CodingMap[NUM_ENCODING_TYPES];                 /* N+1 for N coding types */
DEF int CodingState;
DEF TypCoded *currentCoded;
DEF TypTextBlock *CodingStatusText[MAX_DECODE_THREADS];
DEF int NumStatusTexts;
DEF char uuTable[CODINGTABLESIZE+1]
#ifdef WINMAIN
  = "`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
#endif
;
DEF char xxTable[CODINGTABLESIZE+1]
#ifdef WINMAIN
  = "+-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
#endif
;
DEF char base64Table[CODINGTABLESIZE+1]
#ifdef WINMAIN
  = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
#endif
;

DEF BOOL CodingStatusVerbose;
DEF BOOL BlockCodingStatusAlwaysOnTop;
DEF BOOL MinimizeStatusWindows;
DEF BOOL DumbDecode;
DEF BOOL ExecuteDecodedFiles;
DEF BOOL KeepArticleHeaderVisible;
DEF BOOL AlsoDecodeOpenArticles;
DEF BOOL NeverExeWarnFiles;
DEF HWND hCodedBlockWnd;                /* the block coding status window (top center of screen) */
DEF char UserCodingTable[CODINGTABLESIZE + 1];
#define STATUSWIDTH (85*StatusCharWidth)
#define STATUSHEIGHT (8*StatusLineHeight)

DEF eEncodingType  DefaultEncodingType;
DEF char DefaultEncodingTypeStr[MAXENCODINGTYPELEN];
DEF int DefaultAttachInNewArt;
DEF int DefaultNewArtForAttach;
DEF char DefaultContentType[MAXCONTENTTYPELEN];
DEF char SubjectTemplate[MAXINTERNALLINE];

DEF char FollowupSaysTemplate[MAXINTERNALLINE];
DEF char ReplySaysTemplate[MAXINTERNALLINE];
DEF char IDToken[MAXINTERNALLINE];
DEF char CancelKey[MAXINTERNALLINE];

DEF long ArticleSplitLength;
DEF char MIMEUUType[MAXENCODINGTYPELEN];                /* experimental types used in MIME header gen */
DEF char MIMEXXType[MAXENCODINGTYPELEN];
DEF char MIMECustomType[MAXENCODINGTYPELEN];

DEF char MIMECharset[80];

DEF BOOL GenerateMIME;
DEF BOOL MIMEUsageSuggestions;
DEF BOOL ReviewAttach;
DEF char* MIMEBoundary;

DEF BOOL UsingMIME;                                     /* = TRUE if found MIME Version header in incoming art */

#define CUT_HERE_TEXT  "BEGIN --- CUT HERE --- Cut Here --- cut here ---"

#define FAIL  -1
#define SUCCESS   0
#define ABORT 2
#define CONTINUE 3
#define BUSY 4
#define UNKNOWN 5

#define MIME_VERSION "1.0"
#define ADD_TO_EDIT 1                   /* used for AddEndedLineToBlock  */
#define ADD_TO_POST 2
#define ADD_TO_FILE 3
#define ADD_PLAIN   0

/* Signature File globals */
DEF int EnableSig;
DEF char SigFileName[MAXFILENAME];
DEF TypTextBlock *Signature;
#define BIG_SIG_FILE 40                 /* warning if sig file > this many lines */
#define SIG_DELIMITER "-- "             /* delimiter as defined in Spencer rfc1036++ */


/* Signature truncation globals */
DEF int TruncateSignatures;          /* <> 0 if incoming article signatures are to truncate */
DEF BOOL WithinSignature;
DEF BOOL TruncateSignatureFollowup;

/* Mail List globals  */
DEF TypTextBlock *MailList;
DEF int MailListOrigNum;

/* Smart Filer globals */
DEF TypTextBlock *ExtMapSourceList;
DEF TypTextBlock *ExtMapDosList;
DEF int ExtListOrigNum;
DEF BOOL EnableExtensionConversion;
DEF BOOL SpaceProcessing;
DEF unsigned int MaxFileNameLen;
DEF unsigned int MaxFileExtLen;
DEF int OnDupeName;
DEF int OnNameTooLong;

#define DUPE_AVOID_NONE                 0       /* dupe avoidance list.  these numbers */
#define DUPE_AVOID_NUMBER_EXT   1       /* correspond with posn in droplist */
#define DUPE_AVOID_PREPEND_NUM  2
#define DUPE_AVOID_APPEND_NUM   3

#define SHORTEN_NONE                    0       /* name shotrening list.  these numbers */
#define SHORTEN_TRUNCATE                1       /* correspond with posn in droplist */
#define SHORTEN_SKIP_VOWELS             2

/* bitmaps */
DEF HBITMAP DiskBitmaps[5];
DEF HBITMAP FolderBitmaps[3];
/* toolbar size */
DEF int nToolbarMain;
DEF int nToolbarArt;
DEF int nToolbarView;

DEF char szDownloadSnd[MAXFILENAME];
DEF BOOL EnableDownloadSnd
#ifdef WINMAIN
=FALSE
#endif
;



/* Printing Globals  */
DEF PRINTDLG pd;                                /* Global structure to hold printer defaults */
DEF BOOL PageNumberAlwaysWithSubject;


/* globals for status bar */
typedef struct {
  int dyBorder;                                 /* System Border Width/Height       */
  int dyBorderx2;                               /* System Border Width/Height * 2   */
  int dyBorderx3;                               /* System Border Width/Height * 3   */
  int dyBorderx4;                               /* System Border Width/Height * 4   */
  int dyBorderx8;                               /* System Border Width/Height * 8   */
  int dyBorderx9;                               /* System Border Width/Height * 9   */
  int dyBorderx10;                              /* System Border Width/Height * 10  */
  int dxResize;                                 /* size of gripper */
  int dyStatbar;                                /* Status Bar height                */
  int dxStates;                                 /* Width reserved for State Info    */
  int dxCommMsg;								/* width of comm message area       */
  HFONT hFontStatbar;							/* Font used in status bar */
} ALIGNED STATUSPAINT;
DEF STATUSPAINT StatbarPntData; /* dimensions used in status bar */

/* macros added by jsc */
/* why is there no uitoa!? */
#define uitoa(x,s,b) ultoa((unsigned long)(x),(s),(b))
#define atoui(s) (unsigned int)atol((s))
#define Decoding (CodingState >= DECODE_ACTIVE && CodingState <= DECODE_YENC_HEADER)
#define TextBlockLine(b, n) &(b->text[b->offset[n]])
#define IsBright(c) (GetRValue(c) > 180 && GetGValue(c) > 180 && GetBValue(c) > 180)
#define IsDark(c) (GetRValue(c) < 40 && GetGValue(c) < 40 && GetBValue(c) < 40)
#define RectWidth(r) (r.right - r.left)
#define RectHeight(r) (r.bottom - r.top)

/* Ray Dunn:99/10: Added parenthesis to avoid compiler warnings in MS VC++ 6.0 */
#define ENABLE_MENU   (MF_BYCOMMAND|MF_ENABLED)
#define DISABLE_MENU  (MF_BYCOMMAND|MF_DISABLED|MF_GRAYED)

/* this is the static system color for light gray (C0,C0,C0) */
#define GRAY_COLOR RGB(192,192,192)
#define BLACK_COLOR RGB(0,0,0)

/* Spoiler by shimomai */
#define SpoilChar 0x0c

/* Group/Article list seperator */
DEF int GroupListSeparator;     //shimomai
DEF int ArtListSeparator1;      //shimomai
DEF int ArtListSeparator2;      //shimomai
DEF int ArtListSeparator3;      //shimomai

/* RFC1521/RFC1522 support */
DEF BOOL UseVISUAL1521;
DEF BOOL EncodeRFC1522;
DEF BOOL UseRFC1522;


#define WHEELSCROLL_DONT        0       /* don't scroll by wheel */
#define WHEELSCROLL_SYSTEM  1 /* values from system to scroll; must be 1; see WriteWinVnProfile() winvn.c */
#define WHEELSCROLL_CLICK       2       /* WM_MBUTTONDOWN selects 0... MAX_WHEEL_ENTRIES */
#define WHEELSCROLL_SCROLL      3       /* scrolling with WM_BUTTONDOWN determines PosScrollByWheel */


/* SPI_GETWHEELSCROLLLINES   is also defined in the new winuser.h included 
   in the NT4.0 SDK.  The API SystemParametersInfo in the
   NT4.0 SDK has been updated for the scrolllines   functionality.*/

#ifndef SPI_GETWHEELSCROLLLINES
#define SPI_GETWHEELSCROLLLINES   104
#endif

DEF UINT ucNumLines
#ifdef WINMAIN
=3
#endif
;

DEF BOOL MiddleButton_Is_Down
#ifdef WINMAIN
=FALSE
#endif
;

/* Lines zu scroll by Wheel */
DEF unsigned int AScrollByWheel[MAX_WHEEL_ENTRIES];
DEF unsigned int AScrollMode;
DEF unsigned int APosScrollByWheel
#ifdef WINMAIN
=0
#endif
;
DEF int ATotalDelta
#ifdef WINMAIN
=0
#endif
;

DEF unsigned int GScrollByWheel[MAX_WHEEL_ENTRIES];
DEF unsigned int GScrollMode;
DEF unsigned int GPosScrollByWheel
#ifdef WINMAIN
=0
#endif
;
DEF int GTotalDelta
#ifdef WINMAIN
=0
#endif
;

DEF unsigned int UScrollByWheel[MAX_WHEEL_ENTRIES];
DEF unsigned int UScrollMode;
DEF unsigned int UPosScrollByWheel
#ifdef WINMAIN
=0
#endif
;
DEF int UTotalDelta
#ifdef WINMAIN
=0
#endif
;

DEF unsigned int CScrollByWheel[MAX_WHEEL_ENTRIES];
DEF unsigned int CScrollMode;
DEF unsigned int CPosScrollByWheel
#ifdef WINMAIN
=0
#endif
;
DEF int CTotalDelta
#ifdef WINMAIN
=0
#endif
;

/* MS's SDK for IntelliMouse needs thsi for Win95 and NT3.51 */
DEF UINT uMSH_MOUSEWHEEL
#ifdef WINMAIN
=0
#endif
;   
// MDS support for decoded URL argument to winvn 19991219
typedef struct TypURLStruct {
  char URLServer[MAXNNTPSIZE];
  char URLGroup[MAXGROUPNAME];
  char URLUser[MAXNNTPSIZE];
  char URLPassword[MAXNNTPSIZE];
  char URLPort[MAXNNTPSIZE];
  char URLMessageID[MAXNNTPSIZE]; //or article number
} ALIGNED TypURL;

DEF TypURL *gURLinfo;

// S.Yoshida Search Unread Groups
DEF BOOL ConfigJumpGroup;
DEF BOOL FlagJumpGroup;
 #define JUMPFLAG_ARTICLE 1
 #define JUMPFLAG_GROUP   2
 #define JUMPFLAG_USENET  4

//#define  GJUMP_ENABLE               0x0001
//#define  GJUMP_SPACE                0x0002
//#define  GJUMP_OPENGROUP            0x0004
//#define  GJUMP_OPENART              0x0008
//#define  GJUMP_AUTODETERMINE        0x0010
//#define  GJUMP_SPACEDEFAULT         0x0020
//#define  GJUMP_SKIPHEADER           0x0040
//#define  GJUMP_IGNORENNTP           0x0080
//
//#define  GJUMP_FLG_SPACE            0x0100
//#define  GJUMP_OPN_GROUP            0x0200
//#define  GJUMP_OPN_ARTICLE          0x0400
//#define  GJUMP_OPN_ARTNUM           0x0800
//#define  GJUMP_SETTING_MASK         0x00ff
//#define  GJUMP_STATUS_MASK          0xff00


/* Article available on Server globals */
typedef struct {
   HWND hwnd;
   UINT uMsg;
   WPARAM wParam;
   LPARAM lParam;
} ALIGNED TypMessage;

DEF BOOL ExecAsynMessage
#ifdef WINMAIN
=FALSE
#endif
; /* nothing to execute after startup */

DEF TypMessage AsynMsg;

DEF char TestArticleId[MAXHEADERLINE];
DEF BOOL IsArticleAvailable;

DEF unsigned int InternalTimeoutCounter; /* # of TIMER ticks before sending wakeup */
DEF unsigned int TimeoutCounter;
DEF unsigned int CommTimeout;  //keep alive
DEF unsigned int StallTimeout; // # seconds to wait when expecting data before aborting xfer

#ifdef OFFLINE  // TANAKA Goh
DEF BOOL SaveNewsrcGNUSFormat;
DEF BOOL SaveSOUPOnClose;
#endif


/* WWW Client & FTP Client */
DEF char HttpClient[MAXFILENAME];    //shimomai
DEF char FtpClient[MAXFILENAME];     //shimomai
DEF char GopherClient[MAXFILENAME];  //dumoulin
DEF char WaisClient[MAXFILENAME];    //dumoulin
DEF BOOL UsingDDE;                               //shimomai
DEF int DdeServID;                               //shimomai
DEF char DdeServName[MAXFILENAME];   //dumoulin

#define DDECLIENT_NO_DIRECTIVE  0
#define DDECLIENT_USR_SPECIFIED 1
#define DDECLIENT_NETSCAPE      2
#define DDECLIENT_IEXPLORE      3
#define DDECLIENT_FIREFOX    4

/* Table of mappings between value and string */
struct ValStrTable
{
  int value;
  char *text;
} ALIGNED;

#include <string.h>
#include <stdio.h>                              /* sprintf, etc... */
#include "wvimage.h"

DEF GDIPlusImage g_GDIPlusImage;
DEF HPALETTE g_hPalette;

//#ifdef __cplusplus
//}
//#endif

/*--- Last line of WVGLOB.H -------------------------------------------- */

#endif

/*
 * Local Variables:
 * tab-width: 2
 * end:
 */
