/********************************************************************
 *                                                                  *
 *  MODULE    :  WINVN.H                                            *
 *                                                                  *
 *  PURPOSE   :  Contains all the WinVN function specifications     *
 *                                                                  *
 *******************************************************************/

/*
 * $Id: winvn.h 1.75 1997/03/28 19:44:59 dumoulin Exp $
 */
#ifndef __WINVN__
#define __WINVN__

#ifdef _WIN32
#define __far far
#define huge far
#define __near near
#endif

#ifndef _WIN64
//time calculations are wonky on VS2008 32bit without this
//64bit seems OK -MDS 5/25/08
#define _USE_32BIT_TIME_T 1
#endif

#ifndef WM_DPICHANGED
#define WM_DPICHANGED       0x02E0
#define WM_DPI_UNDOCUMENTED  0x2E1
#define WM_DPICHANGED_BEFOREPARENT      0x02E2
#define WM_DPICHANGED_AFTERPARENT       0x02E3
#define WM_GETDPISCALEDSIZE       0x02E4
#endif

#define NOPALETTERGB(rgb )   (0x00FFFFFF & rgb)

#include <shlobj.h>

int PASCAL WinMain (HINSTANCE, HINSTANCE, LPSTR, int);
BOOL WinVnInit (HINSTANCE hInstance, LPSTR lpCmdLine);

/* Functions define in Ini-News.c */
int fnLocateFiles (HINSTANCE hInstance, LPSTR lpCmdLine);
int ReadSortOption(const char* sDefSort, const char* sGrp);
void WriteSortOption(int iOpt, const char* sGrp);
void WriteDefaultSortOption(int iOpt);

/* (SMR) Changed parameter lists to conform with 3.1 windows.h. */
LRESULT CALLBACK WinVnConfWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK  WinVnViewWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK  WinVnArtWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WinVnArtFaceWndProc( HWND, UINT, WPARAM, LPARAM);

LRESULT CALLBACK  WinVnConfFrameWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK  WinVnViewFrameWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK  WinVnArtFrameWndProc (HWND, UINT, WPARAM, LPARAM);

BOOL GetMemo (HWND, HWND, int);
INT_PTR CALLBACK About (HWND, UINT, WPARAM, LPARAM);
#ifdef WANTOLDACTION
INT_PTR CALLBACK WinVnArticleActionDlg (HWND, UINT, WPARAM, LPARAM);
#endif
INT_PTR CALLBACK WinVnArticleAction (HWND, UINT, WPARAM, LPARAM);

INT_PTR CALLBACK WinVnCommDlg (HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK WinVnSaveArtDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnSaveArtsDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnFindDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnPersonalInfoDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnExecuteInfoDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnConfigConfirmationDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
/* Ray Dunn:99/12: Must use WPARAM & LPARAM, not WORD & LONG (its WORD that's wrong for 32-bit */
INT_PTR CALLBACK WinVnThresholdDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnLogOptDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnDecodeArtsDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnAttachDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnAttachPrefsDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnComposePrefsDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnConfigArticleDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnConfigArticleListDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnConfigGroupListDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnConfigCodingPrefsDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnEncodeDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnExitDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnMailDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnSmartFilerDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnSelectPathDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK WinVnHeadersDlg (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam);   //shimomai
INT_PTR CALLBACK WinVnSMTPDlg (HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK WinVnMergeDlg (HWND, UINT, WPARAM, LPARAM);
INT_PTR CALLBACK WinVnAppendDlg (HWND, UINT, WPARAM, LPARAM);


/* several debug routines */
#ifdef _DEBUG
#if defined(_X86_)
#define DEBUG_BREAK _asm { int 3 }
#else
#define DEBUG_BREAK DebugBreak()
#endif
#else
#define DEBUG_BREAK
#endif

#ifndef TRACE0
#ifdef _DEBUG
#define TRACE0(parm1) {\
    wsprintf(szDebugBuffer,parm1);\
    if(strlen(szDebugBuffer) > sizeof(szDebugBuffer)) DEBUG_BREAK;\
    OutputDebugString(szDebugBuffer);}
#define TRACE1(parm1,parm2) {\
    wsprintf(szDebugBuffer,parm1,parm2);\
    if(strlen(szDebugBuffer) > sizeof(szDebugBuffer)) DEBUG_BREAK;\
    OutputDebugString(szDebugBuffer);}
#define TRACE2(parm1,parm2,parm3) {\
    wsprintf(szDebugBuffer,parm1,parm2,parm3);\
    if(strlen(szDebugBuffer) > sizeof(szDebugBuffer)) DEBUG_BREAK;\
    OutputDebugString(szDebugBuffer);}
#define TRACE3(parm1,parm2,parm3,parm4) {\
    wsprintf(szDebugBuffer,parm1,parm2,parm3,parm4);\
    if(strlen(szDebugBuffer) > sizeof(szDebugBuffer)) DEBUG_BREAK;\
    OutputDebugString(szDebugBuffer);}
#define TRACE4(parm1,parm2,parm3,parm4,parm5) {\
    wsprintf(szDebugBuffer,parm1,parm2,parm3,parm4,parm5);\
    if(strlen(szDebugBuffer) > sizeof(szDebugBuffer)) DEBUG_BREAK;\
    OutputDebugString(szDebugBuffer);}
#define TRACE5(parm1,parm2,parm3,parm4,parm5,parm6) {\
    wsprintf(szDebugBuffer,parm1,parm2,parm3,parm4,parm5,parm6);\
    if(strlen(szDebugBuffer) > sizeof(szDebugBuffer)) DEBUG_BREAK;\
    OutputDebugString(szDebugBuffer);}
//void TRACE(const char *szFormat, ...);

void TRACE(LPCSTR szFormat, ...)
#ifdef WINMAIN
{
	static TCHAR buf[2048];
    va_list vargs;

    if (szFormat && *szFormat) 
    {
		va_start( vargs, szFormat );
		_vsnprintf( buf, 2047, szFormat, vargs );
		va_end( vargs );  

        OutputDebugString(buf);

    }

}
#endif
;

#else
#define TRACE0(parm1)
#define TRACE1(parm1,parm2)
#define TRACE2(parm1,parm2,parm3)
#define TRACE3(parm1,parm2,parm3,parm4)
#define TRACE4(parm1,parm2,parm3,parm4,parm5)
#define TRACE5(parm1,parm2,parm3,parm4,parm5,parm6)
#if (_MSC_VER > 1200)  //1200 = VC6
#define TRACE (void)__noop
#else
#define TRACE (void)0
#endif
#endif
#endif

#ifdef USE_SPLASH
/* in wvsplash.c */
void DisplaySplashScreen (HINSTANCE hInstance, HWND hwnd, int delay);
#endif

/* in file WVUSENET.C */
INT_PTR CALLBACK  About (HWND, UINT, WPARAM, LPARAM);
int BuildGroup(const char *sLine, TypLine *lineptr);
BOOL CrackGroupLine (char *buf, TypLine * lineptr, void*pEndLine);
BOOL CursorToTextLine (int X, int Y, TypDoc * DocPtr, TypBlock far ** BlockPtr,
                       TypLine far ** LinePtr);
int ReadNewsrc (void);
BOOL WriteNewsrc (void);
void SetNetDocTitle (void);
void SetLineFlag (TypDoc * Doc, TypBlock far ** BlockPtr, TypLine far ** LinePtr, int wFlag, int wValue);
void SetExLineFlag (TypDoc * Doc, TypBlock far ** BlockPtr, TypLine far ** LinePtr, int wFlag, int wValue);
void GroupAction (TypDoc * Doc, TypBlock far ** BlockPtr, TypLine far ** LinePtr, int wFlag, int wValue);
void MakeHelpPathName (char *szFileName, int maxchars);
long cursor_to_char_number (long X, long Y, TypDoc * DocPtr, TypBlock far ** BlockPtr, TypLine far ** LinePtr, LPPOINT ptChar=NULL);
void SetGroupActiveLines (void);
void SetSelections (TypDoc * MyDoc, TypLine far * LinePtr);

void SetUserMenus (TypDoc FAR * DocPtr, int enable);
void SetConnectMenuItems (TypDoc FAR * DocPtr, int enable);
void SetGroupMenus (TypDoc far * DocPtr, int enable);
void SetArticleMenus (TypDoc far * DocPtr, int enable);

BOOL MoreInit (void);
void InitAllFonts ();
void InitWinVnFonts ();
void InitCompositionFonts ();
void InitListFonts ();
void InitArticleFonts ();
void InitPrintFonts ();
void InitStatusFonts ();
void DestroyFonts ();
void InitBitmaps ();
void DestroyBitmaps ();
BOOL MainLoopPass (void);
void Connect ();
void Disconnect ();
void Reconnect ();
void AbortAllComm (BOOL bDontKillDecode);
void DropConnection();
BOOL ParseURL( TypURL *pURL, LPSTR lpCmdLine );

void DoHelp (HWND hWnd, UINT nCmd, DWORD dwData);
extern void WINAPI WriteWinvnProfile();
void SaveWindowPositions ();

void MoveCursor ();
BOOL CursorToTextLine (int X, int Y, TypDoc * DocPtr, TypBlock far ** BlockPtr,
                       TypLine far ** LinePtr);
void ViewArticle (TypDoc * Doc, long artindex, BOOL Reuse, BOOL showArt, char far * articleID);
void UnlinkArtsInGroup (TypDoc * GroupDoc);
void UpdateSeenArts (TypDoc * Doc);
void HideShowWindows(int nShow);

/* in file WVBLOCK.C */
int NewBlock (TypBlock far * CurBlockPtr, TypBlock far ** NewBlockPtr);
void SetupEmptyBlock (TypBlock far * BlockPtr, HANDLE hCur, HANDLE hPrev,
                      HANDLE hNext, TypDoc * DocPtr);
BOOL DeleteBlock (TypBlock far ** CurBlockPtr, TypLine far ** CurLinePtr);
int AddLine (TypLine * LineToAdd, TypBlock far ** CurBlockPtr, TypLine far ** CurAddPtr);
BOOL ReplaceLine (TypLine * LineToAdd, TypBlock far ** CurBlockPtr, TypLine far ** CurLinePtr);
BOOL DeleteLine (TypBlock far ** CurBlockPtr, TypLine far ** CurLinePtr);
int NextLine (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
int NextActiveLine (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
int PrevLine (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
int PrevActiveLine (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
int NumBlocksInDoc (TypDoc * Doc);
void ForAllLines (TypDoc * Doc,
                  void lpfnFunc (TypDoc * Doc, TypBlock far ** BlockPtr, TypLine far ** LinePtr, int wFlag, int wValue),
                  int wFlag, int wValue);
void ForAllLinesOnScreen (TypDoc * Doc,
                          void lpfnFunc (TypDoc * Doc, TypBlock far ** BlockPtr, TypLine far ** LinePtr, int wFlag, int wValue),
                          int wFlag, int wValue);
void ForAllBlocks (TypDoc * Doc,
                   void lpfnFunc (TypDoc * Doc, TypBlock far ** BlockPtr, int wFlag, int wValue),
                   int wFlag, int wValue);
void SetForBlock (TypDoc * Doc, TypBlock far ** BlockPtr, int wFlag, int wValue);
BOOL FindLineOrd (TypDoc * Doc, long LineOrd, TypBlock far ** BlockPtr, TypLine far ** LinePtr);
int SearchLine (char *Line, int LineLen, char *Target, int TargLen);
BOOL DoFind (BOOL StartAtTop, BOOL multiSelect, BOOL bReverse);
BOOL TopOfDoc (TypDoc * Doc, TypBlock far ** BlockPtr, TypLine far ** LinePtr);
BOOL BottomOfDoc (TypDoc * MyDoc, TypBlock far ** BlockPtr, TypLine far ** LinePtr);
BOOL ExtractTextLine (TypDoc * Doc, TypLine far * LinePtr, char *Buf, int BufSize);
BOOL LockLine (HANDLE hBlock, unsigned int LineOff, TypLineID FindLineID,
               TypBlock far ** BlockPtr, TypLine far ** LinePtr);
void UnlockLine (TypBlock far * BlockPtr, TypLine far * LinePtr,
             HANDLE * hBlock, unsigned int *LineOff, TypLineID * TheLineID);
void PtrToOffset (TypBlock far * BlockPtr, TypLine far * LinePtr,
             HANDLE * hBlock, unsigned int *LineOff, TypLineID * TheLineID);
TypLineID LineIDtoLinePtr (TypLineID MyLineID, TypDoc far * MyDoc, TypBlock far ** MyBlock, TypLine far ** LinePtr);
unsigned int WhatLine (TypBlock far * BlockPtr, TypLine far * LinePtr);
void MoveBytes (void far * Source, void far * Target, size_t NumBytes);
int InitDoc (TypDoc * Doc, HWND hWnd, TypDoc * Parent, int DType);
void FreeDoc (TypDoc * Doc);
long SizeOfDoc (TypDoc * Doc, long far * nLines);
int mylstrncmp (char far * ptr1, char far * ptr2, int len);
char far *mylstrncpy (char far * ptr1, const char far * ptr2, int len);

/* in file WVSCREEN.C */
void ScreenDown (long nLines, long LinesOnScreen, TypBlock far ** BlockPtr,
                 TypLine far ** LinePtr, long *LinesAdvanced);
void ScreenUp (long nLines, TypBlock far ** BlockPtr, TypLine far ** LinePtr,
               long *LinesBackedUp);
void ScrollIt (TypDoc * Document, WPARAM wParam, LPARAM lParam);
void NewScrollIt (TypDoc * Document, WPARAM wParam, LPARAM lParam);
void HScrollIt (TypDoc * Document, WPARAM wParam, LPARAM lParam);
int LineOnScreen (TypDoc * Doc, HANDLE hTargBlock, unsigned int TargOffset, TypLineID TargLineID);
void NextWindow (HWND hWnd, int docType);
void AdjustMidSc (TypBlock far * BlockPtr, TypLine far * LinePtr);
void AdjustTopSc (TypBlock far * BlockPtr, TypLine far * LinePtr);
void AdjustTopScByDoc (TypDoc * aDoc, TypLineID index);
void ScreenToTop (TypDoc * Doc);
BOOL AdvanceToActive (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
unsigned long ScrollToOrd (unsigned long MaxLinesOrChars, int ScrollPos); 
int OrdToScroll (unsigned long MaxLinesOrChars, unsigned long LineOrd);
   
/* in file WVFILE.c */
int MRROpenFile (char *FileName, int Mode, TypMRRFile ** MRRFile);
DWORD MRRCloseFile (TypMRRFile * MRRFile);
int MRRReadLine (TypMRRFile * MRRFile, char *Linebuf, int Len);
int MRRReadInternalBuff (TypMRRFile *MRRFile);
DWORD MRRWriteLine (TypMRRFile * MRRFile, char far * Linebuf, unsigned int Len);
DWORD MRRWriteBuff (TypMRRFile * MRRFile, char far * Linebuf, unsigned int Len);
DWORD MRRWriteDocument (TypDoc * Document, int Offset, char *szFileName, BOOL Append); 

#ifndef _WIN32
BOOL CopyFile(char *source, char *destin, BOOL bFailIfExists);
#endif

BOOL GetNum (char **ptr, UBIGINT *num);
BOOL GetNum32 (char **ptr, unsigned long *num);
COLORREF StrToRGB (char *cstring);
char *RGBToStr (char *buf, COLORREF rgbVal);
char *StringDate (char *s, time_t time);
void DoCommState (void);
char WasArtSeen (UBIGINT ArtNum, TypGroup far * GroupPtr);
char chROT13 (char achar);
void strROT13 (char *cstring);
void strnROT13 (char *cstring, int len);
BOOL isLineQuotation (char *textptr);
BOOL isSignatureDelimiter(char *textptr);
HBRUSH SetHandleBkBrush (HWND hwnd, HBRUSH handle);
void fakeHostname(char * MyOwnHost);

/* in file WVArt.CPP */
BOOL GetArticleRot13Mode (HWND hWnd);

/* in file WVgroup.CPP */
//extern "C" 
char_p string_compare_insensitive (char_p a, char far * b);
void CheckSortMenuItem(HMENU hMenu, int idItem, int CheckState);
void UncheckAllSortMenuItems(HMENU hMenu);

/* in file WVUTIL.CPP */
WndEdit *getWndEdit (WndEdit * WndEdits, HWND hWnd, int numEntries);
WndEdit *GetComposeWnd (HWND hWnd);
void DoCommInput (void);
void ClearLatestInfo();
int WVMessageBox(HWND hwndParent, UINT idText, UINT idTitle, UINT fuStyle);
int WVTimedMessageBox(HWND hwnd, LPSTR lpText, LPSTR lpCaption,UINT uType);

int WVMessageBox(HWND hwnd, LPSTR lpText, LPSTR lpCaption,UINT uType);
int WVArgMessageBox(HWND hwndParent, UINT idFormat, UINT idTitle, UINT fuStyle, const char far *psubst);
int WVArgXMessageBox(HWND hwndParent, UINT idFormat, UINT idTitle, UINT fuStyle, ...);
BOOL WVSetWindowText(HWND hwndParent, UINT idText);
BOOL WVArgXSetWindowText(HWND hwndParent, UINT idFormat, ...);
BOOL GetRegDefaultCommand(LPCSTR szKey, LPSTR szCommandBuf, int nLen);
char *stristr(const char far *s1, const char far *s2);  //MDS 20000410
DWORD GetDllVersion(LPCTSTR lpszDllName, BOOL* pbIs64bit = NULL);
DWORD GetFileVersion(LPTSTR lpszFilename, LPTSTR lpszDescription=NULL, int nDescLen=-1, BOOL* pBIs64=NULL);
int figurePathFromPidl( LPITEMIDLIST pidl, TCHAR *szRetPath, int nPathLen);
int getSpecialFolder( UINT uCSIDL, TCHAR *szRetPath, int nPathLen);
BOOL WVGetFileWriteTime(LPCTSTR szFile, FILETIME& writeTime);
int SetListSelectedItem(HWND hList, int nSel, BOOL bSel = TRUE);
int GetListSelectedItem(HWND hList);


/* in wvsend.c */
BOOL SendOneLine(char *str);
BOOL SendOneLineWithLen (char *str, unsigned long len);
void GenerateMIMEAttachmentID(int nAttach=-1);



/* in headarray.cpp */
long find_index_from_artnum (long artindex, HANDLE header_handle, HANDLE thread_handle, long length);

/* in file wvheader.c */
void TrimmMultiLineHeader( char *Buf );
BOOL GetHeaderLine (TypDoc * Doc, char *Prefix, char *Buf, int BufLen);
BOOL GetSameHeaderLines(TypDoc * Doc, char *Prefix, char *Buf, int BufLen);
BOOL NextToken (char **cptr);
void AppendTextToEditBuf (char *instr, char far ** buf, long int *left);
void ParseAddress(const char *headerline, char *addressout, long int addressoutlen, char *nameout, long int nameoutlen);

HWND CreateComposeWnd (HWND hWnd, TypDoc * Doc, int DocType);
BOOL GetToAddress (char *buf, int len, TypDoc * refDoc, HWND hWnd);
BOOL GetNewsgroups (char *buf, int len, TypDoc * refDoc);
BOOL GetFromAddress (char *buf, int len, TypDoc * refDoc);
BOOL GetSubject (char *buf, int len, TypDoc * refDoc, int docType);
BOOL GetCcAddress (char *buf, int len, TypDoc * refDoc);
BOOL GetReplyToAddress (char *buf, int len, TypDoc * refDoc);
BOOL GetOrganization (char *buf, int len, TypDoc * refDoc);
BOOL GetFollowupTo (char *buf, int len, TypDoc * refDoc);
BOOL FollowupToPoster (TypDoc * refDoc);
BOOL GetHeaderContents (char *buf, int len, TypDoc * refDoc, char *str);
BOOL GetReferences (char *buf, int len, TypDoc * refDoc);
BOOL GetXref (char *buf, int len, TypDoc * refDoc);
BOOL GetInReplyTo (char *buf, int len, TypDoc * refDoc);
BOOL GetDate (char *buf, int len);
BOOL MakeBody (char **endBuf, TypDoc * refDoc, int docType, HWND hWnd, HWND hWndEdit, BOOL bNoBody);
BOOL GetMailboxDate (char *buf, int len);

/* in file wvcompos.c */
LRESULT CALLBACK WinVnComposeWndProc (HWND, unsigned int, WPARAM, LPARAM);
BOOL CreateEditWnd (WndEdit * compWnd);
BOOL CreateComposeControls (WndEdit * compWnd);
void ResizeComposeControls (WndEdit * compWnd, int cx, int cy);
INT_PTR CALLBACK WinVnControlIntercept (HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL GenerateHeadersForSend (WndEdit * compWnd, TypTextBlock * headers, char *saveSubject, int ConfirmXPost);
void UpdateCancelLock (TypTextBlock * textBlock);
void EnableSendComposition (WndEdit * compWnd, BOOL enable);
BOOL IsAdditionalHeader (const char *line);
BOOL DoEditClose (HWND hWnd, int dirty);

/* In file WVPRINT.C *//* JD 930208 */
BOOL WINAPI PrinterInit (void);
BOOL WINAPI FreePrinterMemory (void);
BOOL WINAPI DeletePrinterDC (HDC);
HDC WINAPI GetPrinterDC (HWND);
BOOL CALLBACK AbortProc (HDC, int);
DWORD WINAPI PrinterSetup (HWND, DWORD);
INT_PTR CALLBACK PrintDlgProc (HWND, UINT, WPARAM, LPARAM);
BOOL WINAPI PrintHeaderP (char *str, int limit);
void WINAPI PrintFile (HWND);
void WINAPI PrintArticle (HWND, TypDoc * Doc);
void WINAPI ReportPrintError (int, HWND);

/* in file wvsckgen.c */
int SetupSock (void);
BOOL PutCommLine (char *line);
BOOL PutCommData (char *data, unsigned int length);
int MRRReadComm (void);
void MRRCloseComm (void);
int MRRInitComm (void);
BOOL MRRInitZStream(int nType);

int send_smtp_line (char *str, unsigned long len);
int post_line (char *str, unsigned long len);
int end_post ();
int end_send_smtp (HWND hWnd = NULL);
int prepare_smtp_message (TypTextBlock * headers, HWND hWnd = NULL);
int prepare_cc_smtp_message (char *destination, TypTextBlock * headers);
int close_smtp_socket (void);

/* In file WVLIST.CPP */
void StartList (void);
void ProcListLine (unsigned char *ListLine);
BOOL AddGroupToTable (char far * GroupLine);
void InitHashTable (unsigned long);
void InitGroupTable (void);
unsigned long HashGroup (unsigned char huge * gname);
void HashNetGroups (TypDoc * Doc, TypLine huge * huge * HashTable);
void BuildPtrList (void);
void BuildHashTable (void);
void ProcEndList (void);
BOOL FreeHashTable();
TypLine * FindHashEntry( char * name);
int GroupCompare (TypLine const huge * huge * g1, TypLine const huge * huge * g2);
INT_PTR CALLBACK WinVnGroupListDlg (HWND hDlg, unsigned iMessage, WPARAM wParam, LPARAM lParam);
void PositionEndSubscribed (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
TypLineID PositionFirstSelected (TypBlock far ** BlockPtr, TypLine far ** LinePtr);
int CompareLineIDPos ( TypLineID nID1, TypLineID nID2 );
void MergeGroups (int WhereSubscribed, TypLineID LineID = 0);
void CleanUpGroupTable (void);
unsigned long FindNextPrime (unsigned long);

/* In file WVMAIL.C  */
/* mlPOPSend (HWND hWnd, char *mBuf); */
int MailClose (HWND hWnd);
void SetMailType (int mailType);
void MailEnableLogout (BOOL enable);
void MailCrashExit (HWND hWnd);
int MailInit (HWND hWnd);

/* In file WVMAPI.C */
int mlMAPIInit (HWND hWnd);
int mlMAPILogout (HWND hWnd);
int mlMAPILogon (HWND hWnd);
int mlMAPISend (HWND hWnd, TypDoc * Doc, int DocType);
/* mlMAPILogon (HWND hWnd); */ 
int mlMAPIClose (HWND hWnd);

/* in WVUTIL.CPP */
BOOL InlineReconnect(HWND hParentWnd);
BOOL InlineGroup(char * szGroup);
void RemoveTrailingWhiteSpace (char *str);
void SubsituteCharInString(char *str, char oldchar, char newchar);
BOOL IsBlankStr (const char *temp);
BOOL isnumber (char *str);
BOOL ValidEmailAddress(char far * name);
char *strntcpy (char *dest, const char *src, int len);
BOOL AskForFont (HWND hParentWnd, char *face, int *size, char *style);
BOOL AskForColor (HWND hParentWnd, COLORREF * color);
BOOL AskForExistingFileName (HWND hParentWnd, char *fileName, char *title);
BOOL AskForExistingFileNames (HWND hParentWnd, TCHAR *fileName, TCHAR *title, TCHAR **files);
char *GetEditText (HWND hWndEdit);
LRESULT SetEditText (HWND hWndEdit, char *editMem);
BOOL WritePrivateProfileInt (const char far * lpAppName, const char far * lpKeyName, int val, const char far * lpProFile);
BOOL WritePrivateProfileUInt (char far * lpAppName, char far * lpKeyName, unsigned int val, char far * lpProFile);
unsigned int GetPrivateProfileUInt (char far * lpAppName, char far * lpKeyName, unsigned int val, char far * lpProFile);
BOOL WritePrivateProfileLong (char far * lpAppName, char far * lpKeyName, long val, char far * lpProFile);
long GetPrivateProfileLong (char far * lpAppName, char far * lpKeyName, long val, char far * lpProFile);

void RefreshGroupWnds (BOOL bReSort);
void RefreshArticleWnds ();
void RefreshStatusWnds ();
void RefreshComposeWnds ();
void BatchSend (int DocType);
BOOL AreComposeWndsDirty();

void CloseWindows ();
void CloseGroupWnds ();
void CloseArticleWnds ();
void CloseComposeWnds ();
void CloseStatusWnds ();

void WinVNCascadeWindows ();

void MinimizeWindows ();
void MinimizeGroupWnds ();
void MinimizeArticleWnds ();
void MinimizeComposeWnds ();
void MinimizeStatusWnds ();

void RestoreWindows ();

BOOL TestCommBusy (HWND hParentWnd, UINT IDmsg);
BOOL TestArgCommBusy (HWND hParentWnd, UINT IDmsg, const char far * psubst);
BOOL TestCodingBusy (HWND hParentWnd, UINT IDmsg);

void SetMainMailMenu (TypDoc FAR * DocPtr);
void SetArticleMailMenu (TypDoc FAR * DocPtr);
void SetGroupMailMenu (TypDoc FAR * DocPtr);
void UpdateAllMailMenus ();

unsigned long GetFreeDiskSpace (char *drive);
unsigned long GetFileLength (const char *fileName);
UBIGINT CalcNumUnread(TypGroup far *GroupPtr);

//S.Yoshida
BOOL RetrieveNextGroup(TypBlock far *BlockPtr, TypLine far *LinePtr, int nTitle, BOOL bConfirm );

/* in file wvfiler.c (jsc) */
char *GetFileExtension (char *tempName, char *fileName);
char *NameWithoutPath (char *tempName, char *fileName);
char *PathWithoutName (char *tempName, char *fileName);
int AskForNewFileName (HWND hParentWnd, char *fileName, char *startDir, BOOL appendOk);
int AskForFilePath (HWND hParentWnd, char *pathName, char *title);
int VerifyFileName (char *fileName);
int SmartFile (HWND hParentWnd, char *fileName);
/* in wvfilter.c */
int MatchFilter (char *group, char *filterBuf);
BOOL strmatch(const char far *text, const char far *pat);
int NumStrCompare(LPCSTR str1, LPCSTR str2, BOOL IgnoreCase, BOOL IgnoreSpace, BOOL AlphaNumOnly);
int NumStrNCompare(LPCSTR str1, LPCSTR str2, int nLen1, BOOL IgnoreCase, BOOL IgnoreSpace, BOOL AlphaNumOnly);

/* In file WVCODING.C */
void DecodeInit (BOOL bRestart);
void DecodeDone (BOOL bWatch = FALSE);
TypCoded *InitCoded (HWND h);
BOOL DecodeLine (TypCoded * thisDecode, char *line, BOOL bMonitor = FALSE);
void DecodeFile (HWND hParentWnd);
void DecodeOpenArticles (HWND hParentWnd, BOOL bMonitor = FALSE);
int DecodeDoc (HWND hParentWnd, TypDoc * Document, BOOL bMonitor = FALSE);
unsigned long EncodeIntoFile (HANDLE hFile, TypAttachment * thisAttach, unsigned long startByte, unsigned long maxBytes);
unsigned long EncodeToTextBlock (TypTextBlock * textBlock, TypAttachment * thisAttach, unsigned long startByte, unsigned long maxBytes);
unsigned long EncodeAndSend (TypAttachment * thisAttach, unsigned long startByte, unsigned long maxBytes);
const char* ParseSubject(const char *line, int* nameLength, int* pnSeq, int* pnTotal, int* pnGroupStart, int* pnGroupEnd, char* pFullName=NULL, int fullnamelen = 0);
BOOL GetPossiblyQuotedStr (char *dest, char *src, int maxLen);
void AddMonitoredFile(HANDLE hProcess, char * szFile);
void CheckMonitoredFiles(BOOL bClose = FALSE);
void CloseMonitoredFiles();
void CrcInit(DWORD* pcrc_val );
void CrcAdd(int c, DWORD* crc_val );
int dehex( int c);


void EncodeToFile (HWND hParentWnd, TypAttachment * attachment);
int CompleteThisDecode ( BOOL bMonitor = FALSE );
int CreateCodingMap (char *map, char *table);
void CreateStatusArea (HWND hParentWnd, char *title, int show);
void DestroyStatusArea ();
void UpdateBlockStatus (BOOL bShowAbort = FALSE, HWND hWndAbort = NULL);
void AddAbortStatus(HWND hAbortNotify = 0);
void UpdateThreadStatus (int num, char *str);
extern int currentDecodeThread;

/* In file WVCODEWN.C */
LRESULT CALLBACK  WinVnCodedBlockWndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK  WinVnCodingWndProc (HWND, UINT, WPARAM, LPARAM);
void RefreshCodedBlockWnd ();
void WVArgMessageLog(const char *format, ...);  // S.Yoshida
void WVMessageLog(const char *);

/* In file WVTXTBLK.C */
TypTextBlock *InitTextBlock (HWND hParentWnd);
TypTextBlock *InitTextBlockWithSize (HWND hParentWnd, unsigned long bytes, unsigned long lines);
void FreeTextBlock (TypTextBlock * textBlock);
BOOL AddLineToTextBlock (TypTextBlock * textBlock, const char *line);
BOOL ReplaceLineInTextBlock (TypTextBlock * textBlock, unsigned long num, char *line);
BOOL AddEndedLineToTextBlock (TypTextBlock * textBlock, char *line);
void ResetTextBlock (TypTextBlock * textBlock);
BOOL ReadFileToTextBlock (HWND hParentWnd, TypTextBlock * block, char *fileName);

/* in file WVATTACH.C */
BOOL SendComposition (WndEdit * compWnd);
void DoSend (int cancel);
void AbortSendPost (HWND hNotifyWnd);

void FinishAttachment (int abort);
eEncodingType EncodingStrToType (const char *str);
const char * EncodingTypeToStr (eEncodingType Type);
void ReadTextFileIntoEditWnd (HWND hEditWnd, char *fileName);

/* In file WVCRYPT.C */
void MRREncrypt (unsigned char *plainText, int len, char *cipherText);
int MRRDecrypt (char *cipherText, unsigned char *plainText, int plainMax);

/* in file WVADDHDR.CPP */
void ResetGlobalAddHdr();
void GlobalGoToNextAddHdr();
BOOL GetGlobalCurrentAddHdr(int *p, char *str);
void ResetGroupAddHdr(TypDoc * Doc);
void GroupGoToNextAddHdr(TypDoc *Doc);
BOOL GetGroupCurrentAddHdr(TypDoc *Doc,int *p, char *str);

/* in file WVSTBAR.C  */
void InitStatBar (STATUSPAINT * StatbarPntData);
void SetNumLockText (HWND hwnd);
void SetCapsLockText (HWND hwnd);
void WVArgXSetStatbarText (HWND hwnd, UINT IDlpszStatBarText, TypDoc * MyDoc, BOOL redrawflg, 
                           BOOL permflg, ...);
void WVArg2SetStatbarText (HWND hwnd, UINT IDlpszStatBarText, TypDoc * MyDoc, BOOL redrawflg, BOOL permflg,
                            const char far *psubst1,const char far *psubst2);
void WVArgSetStatbarText (HWND hwnd, UINT IDlpszStatBarText, TypDoc * MyDoc, BOOL redrawflg, BOOL permflg,
			    const char far *psubst);
void WVSetStatbarText (HWND hwnd, UINT IDlpszStatBarText, TypDoc * MyDoc, BOOL redrawflg, BOOL permflg);
void SetStatbarText (HWND hwnd, LPSTR lpszStatBarText, TypDoc * MyDoc, BOOL redrawflg, BOOL permflg);
void SetStatbarPercent(HWND hwnd, int StatBarPercent, TypDoc * MyDoc, BOOL redrawflg);
void PaintStatbarText(HDC hdc, RECT rcTemp, LPSTR lpszStatBarText, TypDoc *MyDoc);
void PaintStatbar (HWND hwnd, HDC hdc, TypDoc * MyDoc);
void SetConnectionText (HWND hwnd, LPSTR lpszStatBarText, TypDoc * MyDoc, BOOL redrawflg, BOOL permflg);
BOOL StatusBarProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam, TypDoc * MyDoc);
void StatBarMainPopups ();
void StatBarGroupPopups (TypDoc * MyDoc);
void StatBarArtPopups (TypDoc * MyDoc);
void ShellSort (void huge * huge * base, unsigned long nElements,
                size_t width,int (*compare) (void const huge * elem1, void const huge * elem2));


BOOL WINAPI CenterWindow (HWND hwndChild, HWND hwndParent);
BOOL WINAPI GetRelativeWindowPosition(HWND hWndParent, HWND hWndChild, POINT* pptOffset);
BOOL WINAPI SetRelativeWindowPosition( HWND hWndParent, HWND hWndChild, POINT ptOffset);
BOOL MakeRectVisible(RECT& rRect);
void MoveControl(HWND hWnd, UINT nID, int x, int y);
void GrowWindow(HWND hWnd, UINT nID, int x, int y);
BOOL AddLCText(int nItem, int nCol, LPCSTR szText, HWND hList);
const char *WVGetMIMETypeForFile(char *szFile);
LPCSTR FormatNumber( __int64 i, TCHAR * szbuf = NULL);
/* void IncPtr(void **ptr,int incval); */
int xGetWindowDPI(HWND hwnd);

#ifdef JAPANESE
  #ifndef OSCP_THRU
    #define OSCP_THRU           (0)
    #define OSCP_JAP_SJIS       (932)
    #define OSCP_KOR_KSC        (949)
    #define OSCP_CHI_BIG5       (950)
    #define OSCP_CHI_GB         (936)
    #define OSCP__8859_5        (28595)
    #define OSCP__8859_8        (1255)
	#define OSCP__8859_9        (1254)
  #endif
 int WVMultiToUni(wchar_t *out, int out_length, char *in, int in_length, int codepage);
 int WVUniToMulti(char* out, int out_length, wchar_t *in, int in_length, int codepage);
#endif


#define MAXPOPUPS 20
#define TOOMANYARTS (0x40000000L) //128MB = 1billion arts

/* Article status values (Article Action items) */
#define ART_UNSEEN_UNSELECTED 0
#define ART_UNSEEN            0
#define ART_UNSELECTED        0
#define ART_SEEN              1
#define ART_KILLED            2
#define ART_SEENORKILLED (ART_SEEN | ART_KILLED)
#define ART_SELECTED          4
#define ART_REMOVED           8
#define ART_PREVIEW			  16
#define ART_SEENORREMOVED (ART_SEEN | ART_REMOVED)
#define ART_ERROR             128

/* Window word values for child windows */
#define GWW_HWNDEDIT    0
#define GWW_CHANGED     2
#define GWW_WORDWRAP    4
#define GWW_UNTITLED    6
#define CBWNDEXTRA      8

/* String Table constants */

/* path selection bitmap ids, etc */
#ifndef _WIN32
// Private drive types not covered in Win3.x GetDriveType but in Win32
#define DRIVE_CDROM                 5
#define DRIVE_RAMDISK               6
#define SS_SUNKEN
#endif

/* toolbar constants  */
#define CMD_TB_BASE 400
#define MAINTB CMD_TB_BASE+1
#define VIEWTB CMD_TB_BASE+2
#define ARTTB  CMD_TB_BASE+3

#define WM_MYINITMENU      (WM_USER+1024)

#define WM_MYMOUSEWHEEL    (WM_USER+1025)
#define WM_RETHINKTOOLBAR  (WM_USER+1026)
#define WM_MULTIDECODE     (WM_USER+1027)
#define WM_MULTISAVE       (WM_USER+1028)
#define WM_UPDATEFACE	   (WM_USER+1029)
#define WM_ABORTBUTTON     (WM_USER+1030)

/* got from Microsoft's Intellimouse SDK available on http://www.microsoft.com */
#include "zmouse.h"

/*-- Dialog box constants -- */
#include "wvdlg.h"

#include "wv1522c.h"
#include "wvvs1521.h"
#include "resource.h"

#endif

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