/* Copyright 1990,1991,1992,1993,1994,1995,1996,1997,1998,1999 Y&Y, Inc. Copyright 2007 TeX Users Group This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #ifndef _WINDOWS #define _WINDOWS #endif #define NOCOMM #define NOSOUND #define NODRIVERS #define STRICT #include "windows.h" #include "windowsx.h" #include #include #include #include #include "dviwindo.h" #include "winextra.h" #include "winhead.h" #include "winbased.h" #pragma hdrstop #include "ddeml.h" #include "zmouse.h" // MOUSEWHEEL support in Windows 95 and NT 3.51 /* winhead.h not really needed ? */ #include #include /* for demo models mostly */ #include /* needed for drag and drop stuff */ #include /* for EBADF */ #pragma warning(disable:4100) // unreferenced formal parameters /* #define DEBUGINIT */ /* DANGEROUS: ALWAYS REMOVE BEFORE RELEASE !!! */ /* #define DEBUGMAIN */ /* for testing purposes only */ /* #define DEBUGENVIRONMENT */ /* #define DEBUGCHANGE */ /* #define DEBUGEXTRACT */ /* #define DEBUGHYPER */ /* #define DEBUGCOMMAND */ /* #define DEBUGPAGETABLE */ /* #define DEBUGOPEN */ /* good end place for precompiled headers ? */ #define WHEEL_DELTA 120 #define GET_KEYSTATE_WPARAM(wParam) ((short)LOWORD(wParam)) #define GET_WHEEL_DELTA_WPARAM(wParam) ((short)HIWORD(wParam)) /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* #define USEPALETTE */ /* 1996/March/24 experiment */ #define ALLOWDEMO /* demo model - limited lifetime - DANGER ! */ /**************************************************************************** PROGRAM: dviwindo.c PURPOSE: Show DVI files on screen! FUNCTIONS: WinMain() - calls initialization function, processes message loop InitApplication() - initializes window data and registers window InitInstance() - saves instance handle and creates main window MainWndProc() - processes messages About() - processes messages for "About" dialog box PageDlg() - let user select a page. FontDlg() - let user select a font. OpenDlg() - let user select a file, and open it. UpdateListBox() - Update the list box of OpenDlg ChangeDefExt() - Change the default extension SeparateFile() - Separate filename and pathname AddExt() - Add default extension ****************************************************************************/ char *compilefile = __FILE__; char *compiledate = __DATE__; char *compiletime = __TIME__; /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* File Drag and Drop definitions */ /* remove when switching to Win 3.1 */ /****** Drag-and-drop support ***********************************************/ /* from windows.h */ /* #define WM_QUERYDRAGICON 0x0037 */ /* #define WM_DROPFILES 0x0233 */ /* from shellapi.h */ /* UINT WINAPI DragQueryFile(HDROP, UINT, LPSTR, UINT); */ /* BOOL WINAPI DragQueryPoint(HDROP, POINT FAR*); */ /* void WINAPI DragFinish(HDROP); */ /* void WINAPI DragAcceptFiles(HWND, BOOL); */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* specific defines needed in this file only */ /* #define VERSION "1.3.0" */ /* 1995/Nov/17 */ /* #define VERSION "2.0.0" */ /* 1996/Sep/10 */ /* #define VERSION "2.0.1" */ /* 1996/Oct/12 */ /* #define VERSION "2.0.2" */ /* 1997/Jan/5 */ /* #define VERSION "2.0.3" */ /* 1997/Jan/23 */ /* UseNewEncode */ /* #define VERSION "2.0.4" */ /* 1997/Feb/23 */ /* UNICODE fixups */ /* #define VERSION "2.0.5" */ /* 1997/Mar/9 */ /* command flags */ /* #define VERSION "2.0.6" */ /* 1997/Apr/23 */ /* encoding menu */ /* #define VERSION "2.0.7" */ /* 1997/May/25 */ /* demo support */ /* #define VERSION "2.0.8" */ /* 1997/Jul/25 */ /* maximized - Aug 3 */ /* #define VERSION "2.0.9" */ /* 1997/Sep/11 */ /* fix `tex font' bug */ /* #define VERSION "2.0.10" */ /* 1997/Dec/1 */ /* afmtotfm dvipsone call */ /* #define VERSION "2.0.11" */ /* 1998/Jan/12 */ /* Bezier rule fix */ /* #define VERSION "2.0.12" */ /* 1998/Feb/14 */ /* sreadtwo fix */ /* #define VERSION "2.0.13" */ /* 1998/Apr/4 */ /* #define VERSION "2.0.14" */ /* 1998/May/28 */ /* #define VERSION "2.1" */ /* 1998/Jun/10 */ /* RELEASE */ /* #define VERSION "2.1.1" */ /* 1998/Sep/12 */ /* clipping */ /* #define VERSION "2.1.2" */ /* 1998/Nov/4 */ /* synchronicity */ /* #define VERSION "2.1.3" */ /* 1998/Nov/4 */ /* NT 5 T1 fonts */ /* #define VERSION "2.1.4" */ /* 1998/Dec/18 */ /* src editor search */ /* #define VERSION "2.1.5" */ /* 1998/Dec/18 */ /* fix PSfile insertion */ /* #define VERSION "2.1.6" */ /* 1999/Apr/5 */ /* landscape special ignore */ /* #define VERSION "2.1.7" */ /* 1999/May/10 */ /* ExtraSamples in TIFF */ /* #define VERSION "2.1.8" */ /* 1999/May/31 */ /* MultiInstance support */ /* #define VERSION "2.1.9" */ /* 1999/May/31 */ /* AFMtoTFM DLL */ /* #define VERSION "2.1.10" */ /* 1999/Nov/16 */ /* YANDYTEX DLL */ /* #define VERSION "2.2.0" */ /* 1999/Dec/26 */ /* #define VERSION "2.2.1" */ /* 2000/Feb/12 */ /* #define VERSION "2.2.2" */ /* 2000/Apr/8 */ /* #define VERSION "2.2.3" */ /* 2000/May/22 */ #define VERSION "2.2.4" /* 2000/June/17 */ // #define MAXGRAPHICSTACK 16 /* max depth of graphics stack */ /* #define MAXDIRLEN 80 */ /* used by file open dialog */ /* #define MAXSPECLEN 13 */ /* used by file open dialog */ /* #define MAXEXTLEN 5 */ #define SCROLLTHRESH 2 /* used by click and drag */ /* #define SCROLLTHRESH 4 */ /* used by click and drag */ #define SCROLLSTEP 40 #define TICKTOCK 1000 /* milliseconds in timer interval */ /* #define MAXTITLE 20 */ /* (Inactive DVIPSONE) */ #define MAXTITLE 32 /* (Inactive DVIPSONE) */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ int nMagicFact=10000; /* adjust nHeight of fonts 97/Sep/14 */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* Define a structure used to hold info about an app we */ /* start with ExecApp so that this info can be used again */ /* later to test if the app is still running */ // typedef struct _EXECAPPINFO { // HINSTANCE hInstance; /* The instance value */ // HWND hWnd; /* The main window handle */ // HTASK hTask; /* The task handle */ // } EXECAPPINFO, FAR *LPEXECAPPINFO; // EXECAPPINFO TaskInfo; /* place for Task info */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* In the new way, DVISETUP modifies the EXE file directly */ /* newmagic is the old hexmagic string with 8 preliminary bytes added */ /* four are the author signature, four are the serial number * REEXEC */ long serialnumber=0; char newmagic[97]= /* coordinate with winsetup.c */ "bkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkphbkph"; #define hexmagic (newmagic+8) /* start of encrypted owner etc */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* NOTE: following is correct, but differs from what SDK says */ DWORD CombinedVersion; /* set up when starting DOS + Windows version */ WORD WindowVersion; /* set up when starting - Windows version */ WORD DOSVersion=0; /* set up when starting - DOS version */ WORD WinVerNum; /* rearranged bytes of Windows Version 95/Nov/3 */ long xoffset = 0; /* current x offset in mapping to screen */ long yoffset = 0; /* current y offset in mapping to screen */ int wantedzoom = 0; /* current zoom value */ long fontxoffset = 0; /* font show x offset in mapping to screen */ long fontyoffset = 0; /* font show y offset in mapping to screen */ int fontzoom = 0; /* font show zoom value */ /* 96/Aug/26 */ int magbase = 1000; /* user selected base magnification default 1000 */ long pagexoffset = 0; /* page default x offset in mapping */ long pageyoffset = 0; /* page default y offset in mapping */ int pagewantedzoom = 0; /* page default zoom value */ long spreadxoffset = 0; /* spread default x offset in mapping */ long spreadyoffset = 0; /* spread default y offset in mapping */ int spreadwantedzoom = 0; /* spread default zoom value 96/May/12 */ /* ******************************************************************** */ long pagexoffsetsvd = 0; /* page default x offset in mapping */ long pageyoffsetsvd = 0; /* page default y offset in mapping */ int pagewantedzoomsvd = 0; /* page default zoom value */ long spreadxoffsetsvd = 0; /* spread default x offset in mapping */ long spreadyoffsetsvd = 0; /* spread default y offset in mapping */ int spreadwantedzoomsvd = 0; /* spread default zoom value 96/May/12 */ /* ******************************************************************** */ long xoffsetold = 0; /* saved state while showing DVI fonts */ long yoffsetold = 0; int wantedzoomold = 0; /* saved value of wantedzoom while in Font Show */ int metricsize=METRICSIZE; /* 1000 - size used for getting metrics */ int graphicindex = 0; /* stack pointer */ long xoffsetsaved[MAXGRAPHICSTACK], yoffsetsaved[MAXGRAPHICSTACK]; int wantedzoomsaved[MAXGRAPHICSTACK]; /* saved value */ /* need following from winhead.h */ unsigned int TestSize = 20 * 20; /* size to use in tests (TWIPS) */ char TestFont[MAXFACENAME] = ""; /* font name used in tests in winfonts.c */ WORD remaptable[128]; /* cut down 1995/June/23 */ /* unsigned char remaptable[128]; */ COLORREF TextColor; /* RGB(0, 0, 0); default Window Text Color */ COLORREF BkColor; /* RGB(255, 255, 255); default Background Color */ COLORREF OrgBkColor; int RBorderPen=255, GBorderPen=0, BBorderPen=255; /* magenta */ /* int RLinerPen=0, GLinerPen=255, BLinerPen=255; */ int RLinerPen=0, GLinerPen=196, BLinerPen=255; /* cyan */ int RFigurePen=128, GFigurePen=0, BFigurePen=128; /* dark magenta */ DWORD FrameColor = RGB (128, 0, 128); /* default EPS frame color */ char szPreviewHotKey[10]="C-F1"; /* default preview hotkey */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* following are set from [Window] section of dviwindo.ini */ char *szDVIPSONEport=NULL; /* port with PS DVIPSONE printer(s) achPr */ char *szDVIPSONEcom=NULL; /* first item if contains . 95/June/23 achPr */ char *szDVIPSONE=NULL; /* passed to DVIPSONE 94/June/3 achPr */ char *szDVIDistiller=NULL; /* passed to DVIPSONE/Distiller 99/Dec/30 achPr */ char *szAFMtoTFMcom=NULL; /* first item if contains . 95/June/23 achPr */ char *szAFMtoTFM=NULL; /* passed to AFMtoTFM 95/June/26 achPr */ char *szYandYTeX=NULL; /* passed to Y&YTeX 94/July/10 achPr*/ char *szYandYTeXcom=NULL; /* passed to Y&YTeX 94/July/10 achPr */ char *szRegistry=NULL; /* default ttfonts.reg 95/Aug/15 achPr */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* following are set from [Environment] section of dviwindo.ini */ char *szEditorDDE=NULL; /* info to call Editor by DDE 98/Nov/5 achEnv */ char *szTeXEdit=NULL; /* info to call Editor by WinExe 98/Nov/5 achEnv */ char *szCustom=NULL; /* custom encoding name 97/Dec/22 achEnv */ char *szCustomPageSize=NULL; /* custom page size string 2000 May 27 achEnv */ /* ******************* following are from environment variables if defined */ char *szBasePath=NULL; /* non blank if new directory structure 96/Aug/29 */ /* does not include terminating separator ? */ char *szEPSPath=NULL; /* default path from PSPATH */ char *szVecPath=NULL; /* default path from VECPATH */ /* no trailing terminator */ char *szPrePath=NULL; /* default path from PREPATH */ /* no trailing terminator */ char *szTeXFonts=NULL; /* TEXFONTS env variable */ /* or encoding specific env var */ char *szTeXDVI=NULL; /* Y&YTeX DVI output redirection */ /********************************************************************************/ char *logtext=NULL; /* console text buffer 99/Jun/25 */ /********************************************************************************/ char *szWinDir=NULL; /* windows directory 1996/July/23 */ char *szExeWindo=NULL; /* path of executable file */ /* *includes* terminating separator */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ #ifdef AllowCTM BOOL bUseAdvancedGraphics=1; BOOL bAdvancedGraphicsMode=0; BOOL bUseCTMflag=1; /* new 1996/Nov/5 */ #endif /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ unsigned long oneinch=ONEINCH; /* 99/Apr/18 */ unsigned long dvi_num = 25400000; /* default numerator of scale */ unsigned long dvi_den = 473628672; /* default denominator of scale */ unsigned long dvi_mag = 1000; /* default magnification */ unsigned long dvi_l = 0; /* max page height + depth */ unsigned long dvi_u = 0; /* max width */ unsigned long dvi_bytes = 0; /* size of file in bytes */ char dvi_comment[MAXCOMMENT]="No DVI file open"; /* for TeX comment */ int dvi_s = 0; /* max stack depth */ int dvi_t = 0; /* number of pages (bop) in DVI file */ int dvi_version = 0; /* DVI version from header */ int dvi_fonts = 0; /* number of fonts seen */ long current=-1; /* pointer to bop of current page */ /* int maxmarks=0; */ /* maximum number of marks fit in memory allocated */ int nApplications=0; /* number of applications found in [Applications] */ int nEnvironment=0; /* number of vars found in [Environment] */ int nDefaultTIFFDPI=72; /* if resolution not specified in TIFF */ DWORD FileSizeLow; /* 32 low order bits of 64 bit FileSize */ DWORD FileSizeHigh; /* 32 high order bits of 64 bit FileSize */ FILETIME FilewTime; /* 64 bit .dwLowDateTime, .dwHighDateTime */ /* 100 nano sec interval since 1601 Jan 1 */ /* long FileSize; */ /* long FilemTime; */ int nFileMax=0; /* maximum file number findepsfile */ BOOL bUseTimer=1; /* non-zero to use timer to track changes in DVI */ UINT bTimerOn=0; /* non-zero when timer is active */ BOOL bSleeping=0; /* non-zero in iconic state - restart timer later */ UINT nAlarmTicks=0; /* how many clock ticks since change noted */ /* UINT nRefreshDelay=1; */ /* how many clock ticks to wait before refresh */ int nRefreshDelay=0; /* no wait - just refresh 95/Jan/2 new default */ BOOL bAwakened=0; /* non-zero when Timer noted file change */ int OfShareCode = OF_SHARE_DENY_WRITE; /* default for Open File */ int OfExistCode = OF_SHARE_DENY_NONE; /* default for File Exist */ BOOL bSpinOK = 0; /* non-zero if custom spinner child registered */ BOOL bAvoidFlood=1; /* new default 94/Jan/10 */ /* BOOL bPreventConflict=0; */ /* don't WM_PAINT if DVI file in use */ BOOL bPreventConflict=1; /* new default 95/Jan/10 */ BOOL bFloppyDisk=0; /* if DVI file appears to be on floppy disk */ BOOL bHiresScreen=0; /* if screen better than VGA */ BOOL bAllowDrag=1; /* non-zero implies allow drag and drop */ BOOL bUsingDrag=0; /* non-zero if initialized drag-and-drop */ BOOL bAllowCommDlg=1; /* non-zero common dialog box - hard wired 95/Sep/3 */ BOOL bUsingCommDlg=0; /* non-zero if COMMDLG.DLL functions available */ BOOL bDDEServer=1; /* Set up to act as DDE Server 98/Dec/12 */ DWORD idServerInst=0; /* Server instance if DDE Server set up */ BOOL bAddToMRU=1; /* when opening file 99/Jan/3 */ /* set to 0 for INSERT, ... */ /* Avoid use of registry if possible at least in NT --- 1995/Feb/15 */ /* BOOL bUseRegistryFile=1; */ /* OK to try and call RegEdit in Windows 95 */ BOOL bUseRegistryFile=0; /* OK to try and call RegEdit in Windows 95 */ BOOL bRegistrySetup=0; /* If RegEdit has already been called */ BOOL bAlwaysWriteReg=0; /* If set, always dump ttfonts.reg ahead of time */ /* BOOL bUseRegEnumValue=1; */ /* Use KRNL386 imports to registry Windows 95 */ BOOL bUseRegEnumValue=0;/* Use KRNL386 imports to registry Windows 95 */ /* BOOL bNewSearch=0; */ /* non-zero use CommDlg Find Dialog */ BOOL bNewSearch=1; /* non-zero use CommDlg Find Dialog 95/Mar/1 */ BOOL bCompressColor=1; /* compress 24 bit RGB color to palette color */ BOOL bStretchGray=1; /* expand (mingrey - maxgrey) range to full range */ BOOL bStretchColor=1; /* expand color range to use dynamic range properly */ BOOL bBGRflag=0; /* interchange B and R if non-zero */ BOOL bTTRemap=0; /* remap TrueType font control character range */ BOOL bPatchBadTTF=0; /* deal with `text' TTF fonts that aren't */ BOOL bPassThrough=1; /* allow EPS file pass through if PS printer */ BOOL bShowPreview=1; /* non-zero => Show TIFF and EPSI previews */ BOOL bAllowBadBox=1; /* allow single % comment before %%BoundingBox */ BOOL bForceTIFF=0; /* force search for .tif file for .eps file */ BOOL bQuickLink=1; /* non-zero => work around QuickLink II Fax bug */ BOOL bEscapeEnable=1; /* non-zero => Escape exits program */ BOOL bTrueTypeOnly=0; /* non-zero => use only TrueType fonts */ BOOL bTypeOneOnly=0; /* non-zero => use only Adobe Type 1 fonts */ BOOL bHelpAtEnd=0; /* non-zero => move `Help' and `About' to end */ BOOL bRememberDocs=1; /* non-zero => remember opened documents 96/Sep/16 */ BOOL bKeepSorted=1; /* non-zero => keep opened documents sorted 96/Jun/5 */ BOOL bSortEnv=1; /* keep environment sorted 98/Sep/1 */ /* BOOL bUpperCase=1; *//* convert font name to upper case 97/Oct/20 */ BOOL bUpperCase=0; /* change default to 0 when found to be safe */ BOOL bHyperText=1; /* implement hypertext linkage */ BOOL bHyperUsed=0; /* if DVI page contains hypertext linkage */ BOOL bHyperLast=0; /* last mouse action was hyper-tex, not zoom */ BOOL bSourceUsed=0; /* if DVI page contains src linkage */ BOOL bShowButtons=0; /* show hypertext buttons if on */ BOOL bShowViewPorts=0; /* show viewports of Windows MetaFiles */ BOOL bShowWMF=1; /* allow showing of Windows MetaFiles */ BOOL bShowTIFF=1; /* allow showing of TIFF insertimage: */ BOOL bShowFileName=1; /* show name of file for EPS figure w/o preview */ BOOL bShowImage=1; /* show ESPF or TIFF image */ /* 97/Nov/7 */ BOOL bTrueInch=0; /* use true inches in ruler measurement */ BOOL bVerbatimFlag=0; /* non-zero allow verbatim PostScript 96/Oct/2 */ BOOL bAllowAndrew=0; /* try and allow Andrew Trevorrow style */ BOOL bSinglePage=0; /* `Print Current Page' instead of `Print' called */ /* only used to avoid page number overwrite ... */ BOOL bInfoToClip=1; /* copy system info to clipboard */ BOOL bFlipRotate=0; /* flip sign of rotation from PS code */ #ifdef USEUNICODE BOOL bUseNewEncodeTT=0; /* Use UNICODE method for TT encoding 97/Jan/16 */ /* should veto bTTRemap in this case ? */ /* can use NewEncodeTT=1 in Windows 95 */ BOOL bUseNewEncodeT1=0; /* Use UNICODE method for T1 encoding 97/Jan/16 */ /* Both set non-zero in Windows NT */ BOOL bOldUnicode=0; /* Use old UNICODE assignments */ #endif BOOL bDecorative=1; /* Family == FF_DECORATIVE => NOT text font */ /* needed for auto converted T1 fonts in NT */ /* but problem because some TT text set this */ BOOL bDontCare=1; /* Family == FF_DONTCARE => not text font */ /* important for auto converted non text */ BOOL bDrawOutline=1; /* show character outline in ShowFonts */ BOOL bDrawKnots=1; /* draw knots on outline in ShowFonts */ BOOL bDrawControls=1; /* show control points of curveto's */ BOOL bShowCommand=0; /* show command line when entering 99/Apr/11 */ // BOOL bUseAFMtoTFMDLL=0; /* AFMtoTFM.DLL 99/June/13 */ // BOOL bUseYandYTeXDLL=0; /* YANDYTEX.DLL 99/June/13 */ // BOOL bUseDVIPSONEDLL=0; /* DVIPSONE.DLL 99/June/13 */ BOOL bUseDLLs=1; /* use AFMtoTFM.DLL and DVIPSONE.DLL and YandYTeX.DLL */ BOOL bConsoleOpen=1; /* keep Console Window Open */ BOOL bCallBackPass=1; /* callback from dvipsone.dll and passthrough */ BOOL bDontAskFile=1; /* don't ask for file name when "Print to File" */ BOOL bOldPassThrough=0; /* force old PASSTHROUGH even for Distiller */ BOOL bNewPassThrough=0; /* POSTSCRIPT_PASSTHROUGH instead of PASSTHROUGH */ BOOL bForcePassBack=0; /* force passback of print to file output */ BOOL bOpenClosePrinter=0; /* use OpenPrinter/ClosePrinter and StartDoc/EndDocPrinter */ BOOL bOpenCloseChannel=0; /* use OPENCHANNEL/CLOSECHANNEL not STARTDOC/ENDDOC */ BOOL bUseFontName=0; // use FontName instead of FileName in WriteAFM/TFM 2000 July 4 // write TFMs using FontNames, not file names 2000 July 4 #ifdef USEPALETTE BOOL bUsePalette=0; /* 1996/March/24 */ BOOL bUpdateColors=1; /* UpdateColors rather than redraw client area */ HPALETTE hPal=NULL; /* 96/March/24 */ int nUpdateCount = 0; /* how many times UpdateColors has been called */ #endif BOOL bCallSelf=0; /* -1 command flag to call other instance 98/Dec/15 */ BOOL bSearchCall=0; /* -s command flag search call from editor 98/Dec/15 */ BOOL bPageCall=0; /* -p command line flag 99/Jan/10 */ //BOOL bNotFirst=0; /* non-zero if another DVIWindo already running */ BOOL bFirstInst=0; /* zero if another DVIWindo already running */ /* set from DVIWindo_Mutex in WinMain */ BOOL bDebugKernel=0; /* non-zero => running in Windows debug kernel */ BOOL bPrivate=0; /* non-zero => my own copy --- not used ??? */ BOOL bDebug=0; /* non-zero => debugging mode request - command line */ /* 1 => allow only MessageBox / winerror output */ /* 2 => enable also OutputDebugString output */ BOOL bShowCalls=0; /* non-zero => show WinExec calls */ /* controlled by int in Preferences */ BOOL bPauseCalls=0; /* non-zero => pause WinExe calls */ /* controlled and controls by DEBUGPAUSE env var */ /* env var read by DVIPSONE and YANDYTEX => * causes them to show command line if set */ BOOL bDebugMenu=0; /* keep extension of "special" menu for debugging */ BOOL bWin95=FALSE; /* non-zero => Windows 95 (or 98, but not NT) */ BOOL bWin98=FALSE; /* non-zero => Windows 98 (not NT) --- not used */ BOOL bWinNT=FALSE; /* non-zero => Windows NT (or greater, not not 95/98) */ BOOL bWinNT5=FALSE; /* non-zero => Windows NT >= 5 ? W2K */ BOOL bNewShell=FALSE; /* non-zero => new shell (Win 95 user interface) */ BOOL bATM4=FALSE; /* non-zero => ATM 4.0 - used only GetKerningPairs */ BOOL bCommFont=TRUE; /* use new dialogs for fonts etc */ BOOL bLongNames=FALSE; /* show long names in OpenFile dialog 95/Dec/1 */ /* LONGNAMES preprocessor flag stops use OpenFile */ /* use _lopen _lread _lclose instead 95/Dec/1 */ BOOL bGhostHackFlag=FALSE; /* for now */ UINT nDriveD=0; /* drive D: DRIVE_FIXED DRIVE_REMOVABLE DRIVE_REMOTE */ BOOL bReadFile=0; /* non-zero => read requested file when launched */ /* DVI file name given on command line */ BOOL bReadHelp=0; /* non-zero if asked to read help file 2000/Jan/5 */ BOOL bPrintOnly=0; /* print specified file - no screen display */ /* positive means no printer was specified */ /* use default printer in that case */ /* also used by Print Current Page */ BOOL bMultiInstance=0; /* don't call existing instance with file on command line */ BOOL bApplications=0; /* [Applications] section found in DVIWINDO.INI */ BOOL bEnvironment=0; /* [Environment] section found in DVIWINDO.INI */ BOOL bCurrentFlag=1; /* search in current directory first */ /* used in getthepath / expandhash in winsearc.c */ BOOL bUnixify=0; /* convert \ to / when expanding # in TeX Menu */ /* not needed with Y&Y TeX normally ... */ BOOL bUseDVIWindo=1; /* use [Environment] section of `dviwindo.ini' */ /* grabenv otherwise uses getenv DOS env vars */ BOOL bElCheapo=0; /* non-zero => fast/cheap TPIC dashes/splines */ BOOL bAllowTPIC=1; /* non-zero => allow TPIC \specials */ BOOL bAllowClosed=1; /* allow closure of splined curves */ BOOL bGrayFlag = 1; /* gray PREVIOUS & NEXT if appropriate */ BOOL bTeXHelpFlag=0; /* last call from tex menu was to texhelp */ BOOL bTeXHideFlag=0; /* original DVI file saved while TeXHelp */ BOOL bUseWorkPath = 0; /* use DVIWindo `working directory' */ BOOL bUseSourcePath = 1; /* use directory of file TeX worked on */ /* these two ought to be mutually exclusive */ BOOL bUseTeXDVI=0; /* set if TEXDVI environment variable set */ /* all DVI output goes to this directory if set */ BOOL bIgnoreBadANSI=0; /* do not check ANSI encoding violations */ BOOL bNeedANSIacce=0; /* set if char < 32 in ANSI font */ BOOL bNeedANSIwarn=0; /* set if already warned about this */ int nNeedANSIfont=0; /* what font last violated ANSI encoding */ int nNeedANSIchar=0; /* what char violated ANSI encoding ... */ BOOL bIgnoreBadInstall=0; /* do not warn about T1INSTALL problem */ BOOL bT1InstallWarn=0; /* warned about T1INSTALL yet ? */ /* BOOL bT1WarnOnce=1; */ /* warn just for first font */ BOOL bT1WarnOnce=0; /* warn just for first font 96/Nov/30 */ BOOL bUnitsWarned=0; /* if warned yet about bad units in \special */ BOOL bZeroWarned=0; /* if warned about zero width or height */ BOOL bKeepZero=0; /* keep zero size kern pairs in WriteAFM */ int nCmdShowForce=-1; /* negative, or CmdShow for WinExec 94/Mar/7 */ BOOL bQuoteAtSign=0; // replace @.tex with "@.tex" automatically /* 0 Hide, 1 ShowNormal/Normal, 2 ShowMinimized, 3 ShowMaximized/Maximize */ /* 4 ShowNoactive, 5 Show, 6 Minimize, 7 ShowMinNoactive, 8 ShowNA, 9 Restore*/ BOOL bSmallStep=0; /* non-zero for small zoom steps */ BOOL bSciWord=0; /* Scientific Word Figure Inclusion */ BOOL bISOTROPIC=1; /* default MM_ISOTROPIC in MetaFile output */ /* Windows Write cannot handle MM_ISOTROPIC */ /* on the other hand MM_ANISOTROPIC allows unequal scaling */ /* which screws up text since it is only isotropically scalable */ BOOL bBadFileComplained=0; /* have complained aready ? */ BOOL bBadSpecialComplained=0; /* have complained aready ? */ // can't have OLDPRINTDLG defined in WIN32... // #if defined(NEWPRINTDLG) && defined(OLDPRINTDLG) // BOOL bCommPrint=FALSE; /* use new print dialogs 96/Jan/7 */ // #endif BOOL bDismissFlag=1; /* Dismiss Find dialog box 96/Aug/14 */ BOOL bShowFullName=1; /* show full file name in title bar */ BOOL bConvertUnderScores=0; // Convert Underscors to Spaces flipped 2000 July 4 BOOL bAllowFontNames=1; // allow use of FontNames as TFM names 2000 July 4 /* BOOL bSynchronicity=0; */ /* 1998/Nov/5 */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ #define HYPERFILE /* Simple hypertext state push down stack */ /* push graphics state also ? */ long hyperpos[MAXHYPERPUSH]; /* saved position in file */ int hyperpage[MAXHYPERPUSH]; /* saved page number in file */ #ifdef HYPERFILE char *hyperfile[MAXHYPERPUSH]; /* saved file name or NULL -> hMarks */ #endif int hyperindex=0; /* index into the above */ COLORREF CurrentTextColor, CurrentBackColor; /* 1995/April/30 */ COLORREF ColorStack[MAXCOLORSTACK]; int colorindex=0; /* points at next slot to push into */ int bColorUsed=0; /* This DVI file has \special{color ...} */ int bBackUsed=0; /* This DVI file has \special{background ...} */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ HINSTANCE hInst; /* Instance handle */ HINSTANCE hPrevInst; /* Previous Instance handle - not used */ HWND hwnd; /* handle to Main Window - kept global */ HWND hInfoBox=NULL; /* handle to DVIMetric dialog box */ HWND hFntBox=NULL; /* handle to Fonts Used dialog box */ HWND hFindBox=NULL; /* handle to Find Dialog box */ HWND hDlgPrint=NULL; /* handle to abort spooling box */ HWND hConsoleWnd=NULL; /* handle to console text window 99/Jun/25 */ HWND hClientWindow; /* handle to Client Window */ HACCEL hAccTable; /* handle to accelerator table */ HDC hPrintDC=NULL; /* printer DC - keep around ? */ HDC hOldPrintDC=NULL; /* saved printer DC */ HMENU hTeXMenu=NULL; /* made global 1994/Nov/20 */ HMENU hEnvMenu=NULL; /* made global 1998/Aug/28 */ HMENU hHelpMenu=NULL; /* made global 1995/Sep/17 */ /* HDRVR hTIFFLibrary=NULL; */ /* handle of library if loaded */ /* HANDLE hTIFFLibrary=NULL; */ /* handle of library if loaded */ HINSTANCE hTIFFLibrary=NULL; /* handle of library if loaded */ /* or error code < 32 if tried and failed */ HBRUSH hOldBrush; /* not accessed */ HBRUSH hbrBackground; /* not accessed */ HBRUSH hbrDefaultBackground; /* not accessed */ COLORREF clrBackground; HBRUSH hGreyBrush; HBRUSH hLightGreyBrush; HBRUSH hBlackBrush; HBRUSH hRuleBrush=NULL; HBRUSH hRuleBrushDefault=NULL; HPEN hBorderPen; HPEN hLinerPen; HPEN hFigurePen; HPEN hErasePen; HPEN hGreyPen; HPEN hLightGreyPen; HPEN hBlackPen; HPEN hRulePen=NULL; HPEN hRulePenDefault=NULL; HRGN hRgn=NULL; /* place for update region when dragging image around */ HRGN hUpdateRgn=NULL; /* place for incremental update region */ HGLOBAL hFaceNames=NULL; /* handle to memory for font names */ HGLOBAL hFullNames=NULL; /* handle to memory for Full Names (TT) */ HGLOBAL hFileNames=NULL; /* handle to memory for TFM file names */ HGLOBAL hWidths=NULL; /* handle to memory for char widths */ HGLOBAL hPages=NULL; /* handle to memory for page table */ HGLOBAL hBack=NULL; /* handle to memory for page table */ HGLOBAL hColor=NULL; /* handle to memory for color table */ HGLOBAL hTPIC=NULL; /* handle to memory for TPIC path */ /* flushed hMarks 95/Aug/21 since presently not used for hyper-text */ /* HGLOBAL hMarks=NULL; */ /* handle to memory for hyptertext */ HGLOBAL hEncoding=NULL; /* Global Encoding if ENCODING defined 94/Dec/25 */ /* compressed ATM form - not used if bUseNewEncodeT1 */ #ifdef ATMSOLIDTABLE // If we use a single large (huge) table for these encoding data ... HGLOBAL hATMTable=NULL; // global ATM Data for Reencoding 94/Dec/25 char encodefont[MAXFONTS]; // non-zero if encoding already set up #else // If we use separate allocations for each encoding data set HGLOBAL hATMTables[MAXFONTS]; // non-NULL if encoding already set up #endif HGLOBAL hATMShow=NULL; /* Global ATM Data for Show Fonts 94/Dec/25 */ /* Contains 1552 bytes for ATM + encoding + width */ /* BOOL bUseControl=0; *//* use control points in ATM char BBox computation */ BOOL bTraceCurveto=1; /* find extrema in curveto in WriteAFM... */ BOOL bCheckEncoding=1; /* check TFM checksum encoding info in DVI 95/Jan/12 */ /* also now controls BadANSI 97/Feb/18 */ BOOL bUseGetExtent=0; /* GetExtent for char widths 95/Nov/5 */ /* BOOL bViewExtras=1; */ /* View preview info only 95/Mar/28 */ BOOL bViewExtras=0; /* View preview info only 98/Sep/28 */ BOOL bFirstNull=1; /* flush \special start with null 96/Aug/29 */ char srcfile[FILENAME_MAX]; /* reset to "" read from src special 98/Nov/12 */ int srclineno; /* reset to zero read from src special 98/Nov/12 */ int srctaghit; /* set when found src tag in search */ BOOL bMarkSearch=0; /* +1 if searching for mark */ /* +2 if searching for src */ /* BOOL bInverseSearch=0; */ /* non-zero in inverse search (calleditor) mode */ unsigned long nCheckSum=0; /* expected TFM checksum */ /* 95/Feb/3 */ unsigned long nCheckANSI=0; /* expected TFM checksum ansinew */ /* 95/Feb/3 */ BOOL bUseGetProfileATM=0; /* use GetPrivateProfile on atm.ini 95/Feb/3 */ BOOL bUseGetProfileTT=1; /* use GetPrivateProfile on win.ini 95/July/22 */ /* in NT this means getting registry info */ BOOL bUseTTMapping=1; /* Using new mapping table for TT - no more guessing */ /* However the registry has mangled FontNames */ /* while we need FullNames for this to work ... */ BOOL bUseBaseFont=1; /* share metric info for same face and style */ BOOL bIgnoreRemapped=0; /* do not make special case of remapped fonts */ BOOL bUseATMFontInfo=1; /* use ATMGetFontInfo */ BOOL bAllowVersion=1; /* allow mismatch in last char of TT file name */ // BOOL bAllowTruncate=1; /* allow for TFM file name truncation */ BOOL bAllowTruncate=0; /* allow for TFM file name truncation 2000 July 4 */ int BBxll=0, BByll=0, BBxur=0, BByur=0; /* crop \special 96/May/4 */ /* In WIN32 make following LPSHORT instead ??? */ /* LPINT lpWidths; */ /* FAR pointer to char widths table all fonts */ /* LPINT lpCharWidths; */ /* FAR pointer to width table for current font */ /* LPINT lpCharTemp; */ /* FAR pointer to width table for new font */ typedef short int far *LPSHORT; LPSHORT lpWidths; /* FAR pointer to char widths table all fonts */ LPSHORT lpCharWidths; /* FAR pointer to width table for current font */ LPSHORT lpCharTemp; /* FAR pointer to width table for new font */ LPLONG lpPages; /* FAR pointer to page table for current file */ COLORREF FAR *lpBack; /* FAR pointer to background color table */ COLORREF FAR **lpColor; /* FAR pointer to color table for current file */ POINT FAR *lpTPIC; /* FAR pointer to TPIC path table */ /* LPSTR lpApplications; */ /* FAR pointer to string from [Applications] */ /* char *phone="(978) 371-3286"; */ /* not used */ char *TitleText="DVIWindo"; /* normal Window title */ char *version = VERSION; /* Copyright © 1991--1999 Y&Y, Inc. All rights reserved. (978) 371-3286 */ char *copyright="\ Copyright © 1991--2000 Y&Y, Inc. All rights reserved. http://www.YandY.com\ "; #define COPYHASH 6597019 char *szControlName = "DVI Spin"; /* renamed 93/Sep/8 */ char *szControlNameAlt = "AI Bug!"; /* alternate name (NOT longer) */ char *DviWindoClass="DviWindo32"; /* normal Window class */ char *DviWindoMenu= "DviWindoMenu"; /* normal Window menu */ char *szApplication="DVIWindo"; /* used also winanal.c */ char *szTopic="SRCSpecial"; /* used also winanal.c */ char searchtext[MAXSEARCHTEXT]=""; /* place for search text */ /********************************************************************************/ // char IniDefPath[MAXDIRLEN] = ""; /* working directory -- ends in \\ */ char *IniDefPath=NULL; /* working directory if specified */ /* Following used by File Open Dialog */ char OpenName[MAXDIRLEN] = ""; /* copied from IDC_EDIT box */ char DefPath[MAXDIRLEN] = ""; /* default path from DVIPATH */ /* updated from latest file opened */ char DefSpec[MAXDIRLEN] = "*.dvi"; /* default file specification */ /* appears in edit dialog box */ /* seems to be used for file name ? */ char DefExt[MAXDIRLEN] = ".dvi"; /* default extension, includes . */ /* updated from latest file opened */ char SourceOpenName[MAXDIRLEN]=""; /* for calling app - space ? */ char SourceDefPath[MAXDIRLEN]=""; /* default path for application */ char SourceDefSpec[MAXDIRLEN]="*.tex"; /* default file specification */ char SourceDefExt[MAXDIRLEN]=".tex"; /* default extension */ char FileName[MAXFILENAME]=""; /* used by _lopen */ /* ReOpenFile, WM_TIMER DoOpenFile */ /* constructed name of special file */ char szHyperFile[MAXFILENAME]=""; /* temporary use Hyper Text file jump */ /* temporary use Print to File */ /* make following two global to allow for split command strings */ char *szSource=NULL; /* source file name to search for */ int nSourceLine=0; /* line number to search for */ int nPageNum=0; /* page number from command line */ char *ssrc=NULL; /* source file in search call */ char *sdvi=NULL; /* dvi file in search call (and read or print) */ char *szPrintFile=NULL; /* allocate and free to save space */ BOOL bUseFakeFont=1; /* use fake font (Times) for missing fonts */ /* following are fake fonts to use if a font is not found */ int fakeindex = -1; /* index into following table of fake font names */ int fakettf=0; /* is fake font TrueType or Type 1 1995/August/2 */ /* char *FakeFonts[] = { "Times Roman", "Times New Roman PS", "Times New Roman", "Times", "Arial MT", "Gill Sans", "Arial", "Helvetica", "Helv", "Courier", "Courier New", "" }; */ /* List the Type 1 fonts first if possible */ /* List seriffed before sans serif */ /* List variable width before fixed width */ /* This is used in winspeci.c for CaptionFonts also, starting at 4 */ /* Changed `Times Roman' to `Times' (actual Windows Face Name) 96/Apr/30 */ char *FakeFonts[] = { /* "Times Roman", "Times New Roman PS", */ "Times", "Times New Roman PS", "Times New Roman", "Tms Rmn", "Helvetica", "Gill Sans", "Arial MT", "Arial", "Helv", "Courier", "Courier New", "" }; char *textext[32] = { /* 1995/Jun/23 */ "Gamma", "Delta", "Theta", "Lambda", "Xi", "Pi", "Sigma", "Upsilon", "Phi", "Psi", "Omega", "ff", "fi", "fl", "ffi", "ffl", "dotlessi", "dotlessj", "grave", "acute", "caron", "breve", "macron", "ring", "cedilla", "germandbls", "ae", "oe", "oslash", "AE", "OE", "Oslash" }; /* following set from GetClipBox in HSCROLL & VSCROLL - PIXELS */ int width = 1000; int height = 700; /* WORD width = 1000; */ /* WORD height = 700; */ UINT uFindReplaceMsg = 0; /* registered window message for FindText */ /* UINT uFileOKMsg = 0; */ /* registered window message for GetOpenFileName */ BOOL bWrapFlag = 1; /* permit wrap around at end of file in search */ BOOL bCaseSensitive = 0; /* non-zero for case sensitive search */ BOOL bStripPath = 0; /* strip path from ? menu call 96/Oct/4 */ BOOL bNoScriptSel = 0; /* CD_NOSCRIPTSEL winfonts.c 96/Oct/28 */ BOOL bAutoActivate = 1; /* use ATMREG.ATM if possible 96/June/29 default */ /* turned off if ATM loaded and version < 4.0 */ /* turn off in Windows NT ? */ BOOL bUseBase13 = 1; /* Use hard wired info on Base 13 fonts */ BOOL bTryATMRegFlag=1; /* default for now 98/Nov/12 */ /* default increased from 1 => 2 in WIN32 until ATM works ... 95/Nov/5 */ int bUseATMINI = 2; /* use information from ATM.INI for Type 1 */ int bUseTTFINI = 2; /* use information from WIN.INI for TrueTypes */ /* int bUseATMINI = 1; */ /* int bUseTTFINI = 1; */ int bUseUSRINI = 1; /* use substitution file .fnt */ int bUseTEXINI = 1; /* use generic substitution dviwindo.fnt */ BOOL bATMBugFlag=1; /* non-zero => need to correct for ATM bug */ /* remap so old ATM can handle double encoding */ /* Remap=2 needed for TrueType CM fonts */ BOOL bANSITeXFlag=1; /* remap low part of ANSI encoded fonts */ /* BOOL bTeXANSI=0; */ /* value of TEXANSI env var - default 0 */ BOOL bTeXANSI=0; /* value of ANSIBITS env var - default 0 */ /* if ENCODING=ansinew and bTeXANSI=1 actually reencode to ansinew 96/Aug/28 */ /* which will cause bitmapped partial fonts in printed output 96/Aug/28 */ /* otherwise ENCODING=ansinew will mean *no* reencoding right ? */ BOOL bTTUsable=0; /* Is TrueType Enabled (and fonts installed) */ BOOL bTTFontSection=1; /* allow for [TTFonts] as well as [Fonts] */ /* Actually that is now preferred method */ BOOL bUseATM = 1; /* try and connect up to ATM */ BOOL bATMPrefer = 1; /* try and Force Select ATM font */ /* off in Windows NT since no ATMSelectObject */ BOOL bATMExactWidth = 1; /* try and Force ExactWidth for ATM font */ BOOL bATMLoaded = 0; /* if loaded properly and links setup */ /* via GetProcAddress in WIN16 or library WIN32 */ BOOL bATMReencoded = 0; /* non-zero when ATM in reencoded state */ /* HANDLE hATM=NULL; */ /* ATM DLL if loaded */ /* HMODULE hATM=NULL; */ /* ATM DLL if loaded 95/Mar/31 */ #ifdef USEUNICODE BOOL bFontEncoded = 0; /* non-zero if current font is reencoded */ /* using the new method */ #endif BOOL bTeXFontMap = 1; /* allow use of `texfonts.map' for aliasing */ HCURSOR hArrow; /* handle to normal cursor */ HCURSOR hHourGlass; /* handle to hourglass cursor */ HCURSOR hSaveCursor; /* current saved cursor handle/paintpage */ HCURSOR hOldCursor; /* current saved cursor handle/ruler */ HCURSOR hHandCursor=NULL; /* handle to hand cursor */ HCURSOR hZoomCursor=NULL; /* handle to magnifier cursor */ HCURSOR hCopyCursor=NULL; /* handle to magnifier cursor */ HCURSOR hBlankCursor=NULL; /* handle to ruler cursor */ long nFileLength; /* length of file (up to post) */ BOOL bPreferKnown = 0; /* preferences read when we came in */ BOOL bSavePrefer = 1; /* save preferences when exiting */ BOOL bFlipSave = 0; /* flip saving if shift exit */ BOOL bFactory = 0; /* bSafePref reset by Factory Default */ BOOL bShowBorder = 1; /* draw page border */ BOOL bShowLiner = 1; /* draw text outline */ BOOL bResetScale = 0; /* reset scale each file open */ BOOL bResetPage = 1; /* reset scale each new page */ /* flipped the above 1993/Feb/7 */ BOOL bUseNewPageOffset = 1; /* use new page yoffset */ BOOL bComplainMissing = 1; /* complain about missing fonts */ BOOL bComplainSpecial = 1; /* complain about bad \special's */ BOOL bComplainFiles = 1; /* complain about missing EPS files */ BOOL bIgnoreSpecial = 0; /* ignore all \special's */ BOOL bShowBoxes = 1; /* show character boxes */ BOOL bGreyText = 0; /* `greek' text */ BOOL bGreyPlus = 0; /* `greek' text plus text */ BOOL bCarryColor = 1; /* carry color across page boundary */ /* assumed to be on - affects PageCount[] also */ BOOL bAllowClip = 1; /* allow clipping push and pop */ #ifdef IGNORED BOOL bPrintFrame = 0; /* print frames (for alignment) */ #endif BOOL bUseDVIPSONE = 0; /* Use DVIPSONE for printing */ BOOL bRunMinimized = 0; /* Run DVIPSONE minimized */ BOOL bPrintToFile = 0; /* Have DVIPSONE print to file */ BOOL bIgnoreLigatures=1; /* in search, step over ligatures */ BOOL bIgnoreFontCase=1; /* ignore case of Windows Face name */ /* new default value 95/Jan/12 */ BOOL bCollateFlag = 0; /* Collate multiple copy output */ BOOL bUseDevModeCopies = 1; /* Only copies/collate if driver support */ BOOL bUseSharedName = 1; /* Use `shared name' for Ne00: etc */ HWND hWidth=NULL, hHeight=NULL; /* windows for ruler width and height */ BOOL bAltHomeEnd=1; /* alternate use of Home and End keys */ /* for top and bottom of page 98/Jun/30 */ BOOL bLandScape = 0; /* 1 => landscape mode 0 => portrait */ int units = 1; /* units to measure with */ /* see table in winspeci.c */ /* May be able to keep file open, since (20 - 5) = 15 handles per job */ /* and 240 total available */ /* but this stops TeX from making new DVI file */ /* maybe close file when losing focus ? */ BOOL bKeepFileOpen = 0; /* keep file open - 1 untested */ /* Maybe not keep around to avoid tying up a DC ? */ /* But it does slow things down when it has to be recreated ... */ BOOL bKeepPrinterDC = 0; /* keep printer DC open - */ BOOL bKeepDEVMODE = 0; /* keep DEVMODE when opening new printer */ /* BOOL bKeepPrinterDC = 1; */ /* BOOL bKeepDEVMODE = 1; */ BOOL bFileValid = 0; /* non-zero if connected to file */ BOOL bFontSample = 0; /* non-zero if want to show font sample */ BOOL bCharacterSample = 0; /* non-zero if want character sample */ /* (implies bFontSample is also on) */ // UINT nChar=-1; /* which character to show */ int nChar=-1; /* which character to show */ BOOL bShowWidths = 0; /* non-zero if want character widths */ BOOL bWriteAFM = 0; /* 1 if want AFM file */ /* 2 if want AFM *and* TFM file */ BOOL bCountZero=0; /* non-zero => page numbers are TeX count[0] */ BOOL bSpreadFlag=0; /* non-zero => show spread */ BOOL bColorFont = 0; /* non-zero => use different colors */ BOOL bWorkingExists = 0; /* does working directory exist ? 95/July/7 */ /* Next few are really just compile time constants at this point ! */ BOOL bTextOutFlag = 1; /* show text using TextOut */ BOOL bSnapToFlag = 1; /* non-zero means snapto rules */ /* BOOL bDVITypeFlag = 0; */ /* non-zero means modify spacing OLD */ /* negative => don't make small moves */ /* bDVITypeFlag always 0 */ /* BOOL bDVIFakeFlag = 0; */ /* pseudo DVITYPE (above subsumes) */ BOOL bDrawVisible = 1; /* non-zero means refresh only visible */ /* otherwise spew out all */ /* BOOL bUseCharSpacing=1; */ /* Default changed 94/Feb/18 */ /* BOOL bUseCharSpacing=0; */ /* Default changed back 95/Feb/19 */ BOOL bUseCharSpacing=1; /* non-zero use accurate spacing */ /* `Favor Position' IDM_STRINGLIMIT */ BOOL bForceCharSpacing=0; /* non-zero to force in COPY and PRINT */ BOOL bClipRules=1; /* clip rules as well 95/Aug/26 */ BOOL bFixZeroWidth=1; /* fix zero widths RectVisible problem */ int MinWidth = 2 * 20; /* safe minimum RectVisible width in TWIPS 95/Sep/3 */ BOOL bShowInfoFlag = 0; /* show DVI file info in window */ /* (but only if connected to file) */ BOOL bShowInfoExposed = 0; /* showinfo window is not hidden */ /* (hidden if not connected to file) */ BOOL bShowUsedFlag = 0; /* show DVI file fonts in window */ /* (but only if connected to file) */ BOOL bShowUsedExposed = 0; /* usedfonts window is not hidden */ /* (hidden if not connected to file) */ BOOL bShowSearchFlag = 0; /* show modeless Search Dialog Box */ BOOL bShowSearchExposed = 0; /* (hidden if not connected to file) */ int nMapMode=MM_ANISOTROPIC; /* an experiment 96/Aug/8 remove? */ BOOL bShiftFlag = 0; /* non-zero when shift key depressed */ BOOL bControlFlag = 0; /* non-zero when control key depressed */ BOOL bEnableTermination = 0; /* permit early termination */ BOOL bWasIconic = 0; /* prevent double repaint when restore */ BOOL bMaximized = 0; /* Window is maximized *//* 97/Jul/25 */ BOOL bMaximInit = 0; /* read from dviwindo.ini */ BOOL bMaxDriftFlag = 1; /* non-zero implement max drift rule */ BOOL bBusyFlag = 0; /* non-zero while reading page */ BOOL bHourFlag = 0; /* non-zero while hourglass displayed */ BOOL bPrintFlag = 0; /* non-zero when printing */ BOOL bCopyFlag = 0; /* non-zero when copying to ClipBoard */ BOOL bScanFlag = 0; /* non-zero while scandvi... 95/Dec/21 */ BOOL bRectFlag = 0; /* non-zero while setting rectangle */ BOOL bSearchFlag = 0; /* non-zero while searching */ BOOL bUserAbort=0; /* if WM_PAINT was interrupted */ /* used by winprint and winsearc */ /* and by winspeci.c ... */ BOOL bDisableSize = 0; /* on to avoid writing rect size */ RECT UpdateRect; /* rectangle needs update (PRINT/COPY) */ int dvipage = -INFINITY; /* bop count from beginning */ /* physical page count --- starts at 1 */ int gopage=0; /* accumulated page number from keyboard */ BOOL bPageNumber=0; /* non-zero if user has keyed something */ int nCopies=1; /* number of copies to print */ int nDuplex=DMDUP_SIMPLEX; /* Duplex flag from DevMode 96/Nov/17 */ int beginpage=-1; /* set up by print only call */ int endpage=-1; /* set up by print only call */ int bReversePages=0; /* non-zero to reverse page order */ BOOL bOddEven=1; /* use new odd/even page scheme 93/Aug/28 */ BOOL bOddOnly=0; /* show odd pages only (if bOddEven != 0) */ BOOL bEvenOnly=0; /* show even pages only (if bOddEven != 0) */ BOOL bAlternatePages=0; /* alternate pages only (if bOddEven == 0) */ int pageincrement=1; /* set up print only call (if bOddEven == 0) */ BOOL bAspectKeep=1; /* maintain rectangle aspect ratio */ /* Following is used by color coded font code in winanal.c */ int nPaletteOffset=0; /* offset to add to palette index */ int nMaxBright=183; /* maximum grey tone accepted for colors */ int bColorStable=0; /* use f instead of finx[f] in color font */ int nMaxDocuments=9; /* how many listed in File Menu */ /* Following used if bSpreadFlag != 0 && bCountZero != 0 */ long leftcountzero = 0; long rightcountzero = 0; long leftcurrent = 0; long rightcurrent = 0; int leftdvipage = 0; int rightdvipage = 0; BOOL bRuleFillFlag = 1; /* fill rule rectangles */ /* int bUseRect=0; */ /* 1 => use FillRect & FrameRect */ /* which don't work in MetaFile ... */ int bUseRect=2; /* use lines, which work in Acrobat PDF */ /* new default 95/Jan/5 */ BOOL bAvoidZeroWidth = 1; /* non-zero to avoid zero width rules */ BOOL bOffsetRule=0; /* offset rule by 1/2 device pixel */ /* not a good idea 98/Jan/12 */ BOOL bTestFlag=0; /* use for debugging input */ BOOL bIgnoreSelect=0; /* use for debugging input */ BOOL bPreserveSpacing=1; /* non-zero means preserve spacing */ /* zero means preserve shapes */ UINT uMSH_MOUSEWHEEL = 0; // Value returned from RegisterWindowMessage() Windows 95 / NT 3.51 int StringLimit=8; /* max length of contiguous bytes set <= MAXCHARBUF */ #ifdef ALLOWDEMO BOOL bDemoFlag = 0; /* non-zero for DEMO model */ /* as determined by user string DEMO */ time_t dtime=0; /* seconds since customized, now global */ #define oneday (86400) /* one day in seconds */ #define onemonth (86400 * 30) /* one month in seconds */ #endif int papertype = DMPAPER_LETTER; // paper size code /* 0 reserved for custom size 2000 May 27 */ /* DMPAPER_LETTER = 1 */ /* Letter 8 1/2 x 11 in */ /* DMPAPER_LETTERSMALL = 2 */ /* */ /* DMPAPER_LEGAL = 5 */ /* Legal 8 1/2 x 14 in */ /* DMPAPER_A4 = 9 */ /* A4 210 x 297 mm */ /* DMPAPER_A4SMALL = 10 */ /* */ /* DMPAPER_B5 = 13 */ /* B5 176 x 250 mm ? */ /* DMPAPER_TABLOID = 3 */ /* 11 x 17 */ /* DMPAPER_LEDGER = 4 */ /* 17 * 11 */ /* DMPAPER_STATEMENT = 6 */ /* 5 1/2 x 8 1/2 in */ /* DMPAPER_A3 = 8 */ /* 297 x 420 mm */ /* DMPAPER_A5 = 11 */ /* 148 x 210 mm */ /* DMPAPER_B4 = 12 */ /* 182 x 257 mm */ /* DMPAPER_FOLIO = 14 */ /* DMPAPER_QUARTO = 15 */ /* see DMPAPER_... 1 -- 41 in print.h --- or wingdi.h in WIN32 *//* Start of table of paper sizes */ char *papersize[] = { "custom", // 2000 May 27 --- need to treat differently "letter", "lettersmall", "tabloid", "ledger", "legal", "statement", "executive", "a3", "a4", "a4small", "a5", "b4", "b5", "folio", "quarto", /* "10X14", "11X17", "note", */ "" }; /* "", "letter", "lettersmall", "tabloid", "ledger", "legal", "statement", "executive", "A3", "A4", "A4small", "A5", "B4", "B5", */ /* fixed 95/July/10 */ /* DVIPSONE / printer want lower case version */ /* Envelopes: Common #9 (19) Common #10 (20) Common #11 (21) */ /* Envelopes: DL (27) C5 (28) Monarch (37) */ int maxpapersize = sizeof(papersize) / sizeof(papersize[0]); /* default page size for `letter' size in PS points (72 per inch) */ int PageWidth = 612; /* 8.5 * 72 */ int PageHeight = 792; /* 11 * 72 */ int GutterOffset = 0; // allows adjusting gutter in spead mode 00/Jan/09 int CustomPageWidth = 0; // 2000 May 27 int CustomPageHeight = 0; // 2000 May 27 BOOL bPassSize=1; /* pass paper size info 95/Jun/22 */ BOOL bPassOrient=1; /* pass paper orientation info 95/Jun/24 */ BOOL bPassDuplex=1; /* pass printer duplex info 96/Nov/17 */ int xLeft, yTop, cxWidth, cyHeight; /* Main Window Position and Size */ int UsedxLeft=0, UsedyTop=0; /* Fonts Used Window Position */ int InfoxLeft=0, InfoyTop=0; /* DVI File Info Window Position */ int CxLeft=0, CyTop=0, CcxWidth=0, CcyHeight=0; /* Console Window Position and Size */ int QxLeft=0, QyTop=0, QcxWidth=0, QcyHeight=0; /* TeX Query Window Position and Size */ char *achFile=NULL; /* Profile file name - dviwindo.ini */ char *achPr = "Window"; /* Profile file section name */ char *achEnv = "Environment"; /* Profile file section name */ char *achAp = "Applications"; /* Profile file section name */ char *achDocs = "Documents"; /* Profile file section name */ char *achDiag = "Diagnostics"; /* Profile file section name */ char *achEsc = "Escapes"; /* Profile file section name */ char *szEncodingVector=NULL; /* place for encoding vector name */ char *szReencodingVector=NULL; /* ENCODING vector name from ENCODING=... */ char *szReencodingName=NULL; /* ptr into szReencodingVector minus path */ DWORD DVIFilterIndex = 1; /* previously used filter index (DVI files) */ DWORD TeXFilterIndex = 1; /* previously used filter index (TeX files) */ BOOL bUseMagicScreen = 0; /* use nice half-tone screen */ int frompage, topage; /* page range to print - physical pages */ int ScreenFrequency=0; /* screen frequency times ten unless == 0 */ int ScreenAngle=32767; /* screen angle times ten unless == 32767 */ /* MAXPRINTERNAME MAXDRIVERNAME MAXPORTNAME from winhead.h */ // can't have OLDPRINTDLG defined in WIN32... #ifdef IGNORED // #ifdef OLDPRINTDLG /* Keep these names around globally when not using CommDlg */ /* char achPrinter[MAXPRINTERNAME]=""; */ char achDevice[MAXPRINTERNAME]=""; char achDriver[MAXDRIVERNAME]=""; char achPort[MAXPORTNAME]=""; #endif PRINTDLG pd; /* place for new CommDlg structure */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* some prototypes */ void resetinfodetails(void); void setupremaptable(void); int SeparateFile(LPSTR, LPSTR, LPSTR); void ChangeDefExt(PSTR, PSTR); void HideScrollBars(HWND); void ShowEnvironment (void); void CenterThumbs(HWND); /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* HFILE hFile = -1; */ /* DOS file handle */ HFILE hFile = HFILE_ERROR; /* DOS file handle */ HFONT hFontOld=NULL; /* font when we came in */ HFONT hConsoleFont=NULL; /* font used in console window */ #ifndef LONGNAMES OFSTRUCT OfStruct; /* information from OpenFile() */ /* can't use with LONGNAMES !!! */ #endif DWORD NewFileSizeLow; /* 32 low order bits of 64 bit FileSize */ DWORD NewFileSizeHigh; /* 32 high order bits of 64 bit FileSize */ FILETIME NewFilewTime; /* 64 bit .dwLowDateTime, .dwHighDateTime */ /* 100 nano sec interval since 1601 Jan 1 */ /* struct _stat FileStatus; */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ int dragstartx, dragstarty; /* starting point WN_LBUTTONDOWN */ int dragcurrentx, dragcurrenty; /* current point WM_MOUSEMOVE */ int dragendx, dragendy; /* final point WM_LBUTTONUP */ /* WORD dragstartx, dragstarty; */ /* WORD dragcurrentx, dragcurrenty; */ /* WORD dragendx, dragendy; */ BOOL dragflag=0; /* non-zero while dragging image around */ int zoomstartx, zoomstarty; /* starting point WN_LBUTTONDOWN */ int zoomcurrentx, zoomcurrenty; /* current point WN_MOUSEMOVE */ int zoompreviousx, zoompreviousy; /* previous point WN_MOUSEMOVE */ int zoomendx, zoomendy; /* final point WM_LBUTTONUP */ int zoomtemp; /* for interchanging low and high */ /* WORD zoomstartx, zoomstarty; */ /* WORD zoomcurrentx, zoomcurrenty; */ /* WORD zoompreviousx, zoompreviousy; */ /* WORD zoomendx, zoomendy; */ /* WORD zoomtemp; */ BOOL bZoomFlag=0; /* non-zero while defining zoom rect */ /* negative after WM_ZOOM before drag */ /* positive while dragging */ /* BOOL bClipFlag=0; */ /* non-zero while defining clip rect */ /* neg after WM_CLIPBOARD before drag */ /* see bRectFlag ! */ /* positive while dragging */ BOOL bRuleFlag=0; /* non-zero while drawing ruler */ /* neg after WM_RULE before drag */ /* positive while dragging */ /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ unsigned long checkcopyright(char *s) { int c; unsigned long hash=0; while ((c = *s++) != '\0') { hash = (hash * 53 + c) & 16777215; } if (hash == COPYHASH) return 0; /* change if copyright changed */ sprintf(debugstr, "EXE FILE CORRUPTED %ld\n", hash); OutputDebugString(debugstr); /* This will hang some systems !!! Good !!! */ return hash; } /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ static char *modname = "DVIWINDO"; /* static char *modname = __FILE__; */ static void winerror (char *message) { HWND hFocus; if ((hFocus = GetFocus()) == NULL) hFocus = hwnd; (void) MessageBox(hFocus, message, modname, MB_ICONSTOP | MB_OK); } /* static void wininfo(char *message) */ void wininfo (char *message) { HWND hFocus; if ((hFocus = GetFocus()) == NULL) hFocus = hwnd; (void) MessageBox(hFocus, message, modname, MB_ICONINFORMATION | MB_OK); } static int wincancel (char *buff) { /* 1993/March/15 */ HWND hFocus; int flag; if ((hFocus = GetFocus()) == NULL) hFocus = hwnd; flag = MessageBox(hFocus, buff, modname, MB_ICONSTOP | MB_OKCANCEL); if (flag == IDCANCEL) return -1; else return 0; } int wincancelinfo (char *buff) { /* 1993/March/15 */ HWND hFocus; int flag; if ((hFocus = GetFocus()) == NULL) hFocus = hwnd; flag = MessageBox(hFocus, buff, modname, MB_ICONINFORMATION | MB_OKCANCEL); if (flag == IDCANCEL) return -1; else return 0; } /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* stuff for encrypting and decrypting */ unsigned char decryptbyte (unsigned char cipher, unsigned int *crypter) { unsigned char plain; /* plain = (cipher ^ (unsigned char) (*crypter >> 8)); */ plain = (unsigned char) ((cipher ^ (unsigned char) (*crypter >> 8))); /* *crypter = (cipher + *crypter) * CRYPT_MUL + CRYPT_ADD; */ *crypter = (unsigned int)((cipher + *crypter) * CRYPT_MUL + CRYPT_ADD); return plain; } /* 0 box when not customized when starting */ /* 1 IDM_SYSFLAGS */ /* 2 OutputDebugString when starting DVIWindo */ /* void notcustomized (void) */ /* void showconfiguration (int flag) */ /* Modified 1996/April/5 */ void ShowConfiguration (char *buffer) { /* Modified 1996/Nov/7 */ sprintf(buffer, "\ Win 95: %d, Win 98: %d, Win NT: %d, New Shell: %d, W2K: %d,\n\ ATM loaded: %d, TTF usable: %d\n", bWin95, bWin98, bWinNT, bNewShell, bWinNT5, bATMLoaded, bTTUsable); } /* sets up a string with video setup properties */ void showscreensize (char *buffer) { int nBitsPerPixel, nPlanes, nColorRes, nNumColors; int nLogicalX, nLogicalY, nHorzRes, nVertRes; HDC hDC; char *s; hDC = GetDC (hwnd); nBitsPerPixel = GetDeviceCaps (hDC, BITSPIXEL); nPlanes = GetDeviceCaps (hDC, PLANES); nColorRes = GetDeviceCaps (hDC, COLORRES); nNumColors = GetDeviceCaps (hDC, NUMCOLORS); nLogicalX = GetDeviceCaps (hDC, LOGPIXELSX); nLogicalY = GetDeviceCaps (hDC, LOGPIXELSY); nHorzRes = GetDeviceCaps (hDC, HORZRES); nVertRes = GetDeviceCaps (hDC, VERTRES); (void) ReleaseDC (hwnd, hDC); s = buffer; if (nNumColors < 0) nNumColors = 0; sprintf(s, "%d BitsPerPixel, %d Plane%s, %d ColorRes, %u %s,\n", nBitsPerPixel, nPlanes, (nPlanes > 1) ? "s" : "", nColorRes, nNumColors, (nNumColors > 0) ? "Basic Palette" : "True Color"); s = buffer + strlen(buffer); sprintf(s, "%d x %d logical dpi on %d x %d screen\n", nLogicalX, nLogicalY, nHorzRes, nVertRes); } /* used to have showowner here -> with About Dialog box code in winprint.c */ /* check encrypted owner tampering */ /* decrypted format is "Berthold K.P. Horn@100@1997 May 23 07:43:48\n" */ int checkowner (char *hex, char *buffer, int nlen) { unsigned int cryptma = REEXEC; unsigned char e=0; /* avoid uninitialized message 98/Mar/26 */ int i, k; char *s=hex; char *t=buffer; /* should be enough space there */ #ifdef DEBUGINIT if (bDebug > 1) OutputDebugString("Check owner\n"); #endif /* check first whether it is pre-customized version of executable */ i = 0; /* first check on pre-release version */ for (k = 4; k < 32; k++) { /* assumes pattern wavelength 4 */ if (*(s+k) != *(s+k-4)) { i = 1; break; } } if (i == 0) { /* uncustomized */ ShowConfiguration(str); strcat(str, "\n"); showscreensize(str + strlen(str)); *(str + strlen(str) - 1) = '\0'; /* trailing \n */ wininfo(str); if (wincancel("SORRY: NOT CUSTOMIZED!") < 0) PostQuitMessage(0); if (getenv("CARLISLE") == NULL && getenv("CONCORD") == NULL && getenv("CAMBRIDGE") == NULL && getenv("CONWAY") == NULL) return -1; /* kill it then */ return 0; } /* modified 97/May/23 to allow Windows ANSI accented characters, */ /* but also now disallows control characters, and checks signature */ for (i = 0; i < 4; i++) { e = decryptbyte((unsigned char) *s++, &cryptma); /* if (e < 32 || e > 126) */ if (e < 'a' || e > 'z') { /* should be all lower case */ #ifdef DEBUGINIT if (bDebug > 1) OutputDebugString("Signature\n"); #endif return -1; /* tampered with signature */ } } for (i = 4; i < nlen; i++) { e = decryptbyte((unsigned char) *s++, &cryptma); *t++ = e; /* assemble line */ if (e == 0) break; if (e < 32) { if (e != 10 && e != 13 && e != 9) break; /* tampered with ! */ } else if (e > 127) { if (e < 192) { if (e != 138 && e != 140 && e != 154 && e != 156 && e != 159 && e != 145 && e != 146) break; /* tampered with ! */ /* 138 (Scaron) 140 (OE) 154 (scaron) 156 (oe) 159 (Ydieresis) */ /* 145 (quoteleft) 146 (quoteright) */ } else if (e == 215 || e == 247) break; /* tampered with ! */ /* 215 (multiply) 247 (divide) */ } } if (e != 0) *t++ = '\0'; #ifdef DEBUGINIT if (bDebug > 1) OutputDebugString(buffer); /* show signature ??? */ #endif if (e != 0) return -1; if (strchr(buffer, '@') == NULL) return -1; /* tampered with */ #ifdef ALLOWDEMO /* if (strstr(buffer, "DEMO") != NULL) bDemoFlag = 1; */ /* else bDemoFlag = 0; */ #endif if ((s = strstr(buffer, "DEMO")) != NULL) { /* 98/May/20 */ if (sscanf(s+4, "%d", &bDemoFlag) == 0) bDemoFlag = 1; } return 0; /* seems ok ! */ } /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* Thu Sep 27 06:26:35 1990 => 1990 Sep 27 06:26:35 */ void lcivilize (char *date) { int k; char year[6]; if (date == NULL) return; /* sanity check */ strcpy (year, date + 20); for (k = 18; k >= 0; k--) date[k+1] = date[k]; date[20] = '\n'; date[21] = '\0'; for (k = 0; k < 4; k++) date[k] = year[k]; date[4] = ' '; return; } /* Split up default info line in dviwindo.ini into DefPath, DefSpec DefExt */ /* Typically Defaults=D:\working\ *.dvi .dvi /* First item may be quote delimited "..." */ void splitupdefaults (char *buff, char *DefPath, char *DefSpec, char *DefExt) { int done=0; char *s, *t, *u; // bDebug = 2; // debugging only !!! #ifdef DEBUGOPEN if (bDebug > 1) { OutputDebugString(buff); // wincancel(buff); // debugging only } #endif s = buff; if (*s == '\0') return; /* nothing there ! */ if (*s == '\"') { /* handle quoted string here 97/Dec/10 */ t = strchr(s+1, '\"'); if (t != NULL) *t = '\0'; // flush second " strcpy(s, s+1); // flush first " // s = s + strlen(s); // s += 2; s = t + 1; // start of second field while (*s <= ' ' && *s > '\0') s++; // over white space } else { /* Revised 1997/Dec/10 to look for "\ " for paths with spaces */ // t = s + strlen(s) - 1; // ??? if ((s = strstr(s, "\\ ")) != NULL) s++; /* 97/Dec/10 */ // else if (*t == '\\' || *t == '/') s = t+1; // ??? else { /* resort to the old way */ s = buff; // fixed 2000 June 17 while (*s > ' ') s++; /* find first white space - the old way */ } if (*s == '\0') done = 1; /* last field ? */ else *s++ = '\0'; /* mark end of first field */ } /* at this point, s points at start of second field */ t = buff; /* if (strlen(t) < MAXPATHLEN) strcpy(DefPath, t); */ /* if (strlen(t) < sizeof(DefPath)) strcpy(DefPath, t); */ if (strlen(t) < MAXDIRLEN) strcpy(DefPath, t); t = s; /* make sure it has a drive in it and ends with backslash */ if (strchr(DefPath, ':') == NULL && strncmp(DefPath, "\\\\", 2) != 0) // 2000 May 22 DefPath[0] = '\0'; /* protection */ else { /* 1993/Dec/21 */ u = DefPath + strlen(DefPath) - 1; if (*u != '\\' && *u != '/') strcat(DefPath, "\\"); } if (bDebug > 1) { sprintf(debugstr, "DefPath '%s' s '%s' t '%s'", DefPath, s, t); OutputDebugString(debugstr); // wincancel(debugstr); // debugging only } // temporary fix to avoid replication of bad DefPath 2000/March/15 // if ((u = strstr(DefPath, "\\\\\\")) != NULL) *(u+1) = '\0'; if (done) return; /* there was only one field */ /* at this point, s and t point at start of second field */ while (*s > ' ') s++; /* find next blank field separator */ if (*s == '\0') done = 1; /* last field ? */ else *s++ = '\0'; /* mark end of second field */ /* if (strlen(t) < MAXSPECLEN) strcpy(DefSpec, t); */ /* if (strlen(t) < sizeof(DefSpec)) strcpy(DefSpec, t); */ if (strlen(t) < MAXSPECLEN) strcpy(DefSpec, t); t = s; if (bDebug > 1) { sprintf(debugstr, "DefSpec '%s' s '%s' t '%s'", DefSpec, s, t); OutputDebugString(debugstr); // wincancel(debugstr); // debugging only } *DefExt = '\0'; /* in case there is no default extension */ if (done) return; /* at this point, s and t point at start of third field */ while (*s > ' ') s++; /* find next blank */ if (*s == '\0') done = 1; /* last field ? */ else *s++ = '\0'; /* mark end of field */ /* if (strlen(t) < MAXEXTLEN) strcpy(DefExt, t); */ /* if (strlen(t) < sizeof(DefExt)) strcpy(DefExt, t); */ if (strlen(t) < MAXEXTLEN) strcpy(DefExt, t); /* t = s; */ /* make sure it starts with period */ if (*DefExt != '.') { strcpy(DefExt, "."); strcat(DefExt, t); } t = s; /* moved here 93/Dec/5 */ if (bDebug > 1) { sprintf(debugstr, "DefExt '%s' s '%s' t '%s'", DefExt, s, t); OutputDebugString(debugstr); // wincancel(debugstr); // debugging only } if (bDebug > 1) { sprintf(debugstr, "DefPath '%s' DefSpec '%s' DefExt '%s'\n", DefPath, DefSpec, DefExt); OutputDebugString(debugstr); // wincancel(debugstr); // debugging only } /* if (done != 0) return; */ } /* check whether filename given corresponds to currently open DVI file */ /* try both quoted and unquoted version - ignore case, of course */ /* do we also need to bother about \ versus / ? hope not ... 98/Dec/12 */ int IsCurrentFile (char *FileName) { if (bFileValid == 0) return 0; strcpy(str, "\""); strcat(str, DefPath); strcat(str, DefSpec); strcat(str, "\""); #ifdef DEBUGHYPER if (bDebug > 1) { OutputDebugString(str); OutputDebugString(FileName); } #endif if (_strcmpi(str, FileName) == 0) return 1; strcpy(str, DefPath); strcat(str, DefSpec); if (_strcmpi(str, FileName) == 0) return 1; return 0; } void setpagesize (int type) { switch (type) { /* 0 */ /* custom size - at end */ case DMPAPER_LETTER: /* 1 */ /* Letter 8 1/2 x 11 in */ case DMPAPER_LETTERSMALL: /* 2 */ /* Letter Small 8 1/2 x 11 in */ PageWidth = 612; /* 8.5 * 72 */ PageHeight = 792; /* 11 * 72 */ /* fixed 96/Sep/22 */ break; case DMPAPER_TABLOID: /* 3 */ /* Tabloid 11 x 17 in */ PageWidth = 792; /* 11 * 72 */ PageHeight = 1224; /* 17 * 72 */ break; case DMPAPER_LEDGER: /* 4 */ /* Ledger 17 x 11 in */ PageWidth = 1224; /* 17 * 72 */ PageHeight = 792; /* 11 * 72 */ break; case DMPAPER_LEGAL: /* 5 */ /* Legal 8 1/2 x 14 in */ PageWidth = 612; /* 8.5 * 72 */ PageHeight = 1008; /* 14 * 72 */ break; case DMPAPER_STATEMENT: /* 6 */ /* Statement 5 1/2 x 8 1/2 in */ PageWidth = 396; /* 5.5 * 72 */ PageHeight = 612; /* 8.5 * 72 */ break; case DMPAPER_EXECUTIVE: /* 7 */ /* Executive 7 1/4 x 10 1/2 in */ PageWidth = 522; /* 7.25 * 72 */ PageHeight = 756; /* 10.5 * 72 */ break; case DMPAPER_A3: /* 8 */ /* A3 297 x 420 mm */ PageWidth = 842; /* 297 * 72 / 25.4 */ PageHeight = 1190; /* 420 * 72 / 25.4 */ break; case DMPAPER_A4: /* 9 */ /* A4 210 x 297 mm */ case DMPAPER_A4SMALL: /* 10 */ /* A4 Small 210 x 297 mm */ PageWidth = 596; /* 210/25.4 * 72 */ PageHeight = 842; /* 297/25.4 * 72 */ break; case DMPAPER_A5: /* 11 */ /* A5 148 x 210 mm */ PageWidth = 420; /* 148 * 72 / 25.4 */ PageHeight = 596; /* 210 * 72 / 25.4 */ break; case DMPAPER_B4: /* 12 */ /* B4 (JIS) 250 x 354 */ PageWidth = 709; /* 250 * 72 / 25.4 */ PageHeight = 1003; /* 354 * 72 / 25.4 */ break; case DMPAPER_B5: /* 13 */ /* B5 (JIS) 182 x 257 mm */ PageWidth = 499; /* 176/25.4 * 72 ? */ PageHeight = 709; /* 250/25.4 * 72 ? */ break; case DMPAPER_FOLIO: /* 14 */ /* Folio 8 1/2 x 13 in */ PageWidth = 612; PageHeight = 936; break; case DMPAPER_QUARTO: /* 15 */ /* Quarto 215 x 275 mm */ PageWidth = 632; PageHeight = 780; break; case DMPAPER_LETTER + IDM_CUSTOMSIZE - IDM_LETTER: /* 0 */ /* custom size */ if (CustomPageWidth > 0 && CustomPageHeight > 0) { PageWidth = CustomPageWidth; PageHeight = CustomPageHeight; } break; default: /* letter */ PageWidth = 612; /* 8.5 * 72 */ PageHeight = 792; /* 11 * 72 */ break; } } /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ void setoffsetandzoom (int flag) { /* 1996/May/12 */ if (flag) { /* reset to defaults if flag non-zero */ if (bSpreadFlag == 0) { xoffset = pagexoffset; yoffset = pageyoffset; wantedzoom = pagewantedzoom; } else { xoffset = spreadxoffset; yoffset = spreadyoffset; wantedzoom = spreadwantedzoom; } } else { /* switch page to/from spread if flag zero */ if (bSpreadFlag == 0) { /* switching from spread to normal */ spreadxoffsetsvd = xoffset; /* save spread state */ spreadyoffsetsvd = yoffset; spreadwantedzoomsvd = wantedzoom; xoffset = pagexoffsetsvd; /* restore normal state */ yoffset = pageyoffsetsvd; wantedzoom = pagewantedzoomsvd; } else { /* switching from normal to spread */ pagexoffsetsvd = xoffset; /* save normal state */ pageyoffsetsvd = yoffset; pagewantedzoomsvd = wantedzoom; xoffset = spreadxoffsetsvd; /* restore spread state */ yoffset = spreadyoffsetsvd; wantedzoom = spreadwantedzoomsvd; } } } int sameoffsetandzoom (void) { /* predicate 1996/May/12 */ if (bSpreadFlag == 0) { if (xoffset == pagexoffset && yoffset == pageyoffset && wantedzoom == pagewantedzoom) return 1; else return 0; } else { if (xoffset == spreadxoffset && yoffset == spreadyoffset && wantedzoom == spreadwantedzoom) return 1; else return 0; } } /* include more ? */ void readpreferences(void) { /* read stuff from private profile file */ int k; if (achFile == NULL) return; (void) GetPrivateProfileString(achPr, "Preferences", "", str, sizeof(str), achFile); if (*str != '\0') /* only if there is something 94/Feb/18 */ sscanf(str, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\ %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\ %d %d %d", &bSpreadFlag, &bCountZero, &bLandScape, &bGreyText, &bGreyPlus, &bColorFont, &bRuleFillFlag, &bShowBorder, &bShowLiner, &bResetScale, &bShowBoxes, &bCaseSensitive, &bWrapFlag, &bComplainMissing, &bComplainSpecial, &bIgnoreSpecial, &bResetPage, &bUseDVIPSONE, &bPrintToFile, &bPassThrough, &papertype, &bUseCharSpacing, &bShowButtons, &bReversePages, &bTrueInch, &bComplainFiles, &bShowPreview, &bCheckEncoding, &bViewExtras, &bDismissFlag, &bShowViewPorts, &bShowCalls, &nDuplex, &bShowTIFF, &bShowWMF); (void) GetPrivateProfileString(achPr, "Preferences2", "", str, sizeof(str), achFile); if (*str != '\0') /* only if there is something 94/Feb/18 */ sscanf(str, "%d %d %d %d %d %d %d %d %d %d", &bCallBackPass, &bConsoleOpen, &bOpenCloseChannel, &bNewPassThrough, &bForcePassBack, &bDontAskFile, &bOldPassThrough, &bUseDLLs, &bOpenClosePrinter, &bUseFontName); /* fixed 97/Feb/18 */ if (bDebug == 1) bShowCalls = 1; /* backward compatability ??? */ if (bGreyText != 0) bGreyPlus = 0; /* mutually exclusive */ if (nDuplex == 0) nDuplex = DMDUP_SIMPLEX; /* if (papertype > MAXPAPERSIZE) papertype = MAXPAPERSIZE; */ if (papertype >= maxpapersize) papertype = maxpapersize-1; /* get default page position and magnification */ (void) GetPrivateProfileString(achPr, "Mapping", "", str, sizeof(str), achFile); sscanf(str, "%ld %ld %d", &pagexoffset, &pageyoffset, &pagewantedzoom); /* set initial saved state for normal display mode 96/May/12 */ pagexoffsetsvd = pagexoffset; pageyoffsetsvd = pageyoffset; pagewantedzoomsvd = pagewantedzoom; /* get default page position and magnification font showing */ /* 96/Aug/26 */ (void) GetPrivateProfileString(achPr, "FontMapping", "", str, sizeof(str), achFile); sscanf(str, "%ld %ld %d", &fontxoffset, &fontyoffset, &fontzoom); /* get default spread position and magnification 1996/May/12 */ (void) GetPrivateProfileString(achPr, "SpreadMapping", "", str, sizeof(str), achFile); if (sscanf(str, "%ld %ld %d", &spreadxoffset, &spreadyoffset, &spreadwantedzoom) < 3) { spreadxoffset = pagexoffset; spreadyoffset = pageyoffset; spreadwantedzoom = pagewantedzoom; } /* set initial saved state for spread display mode 1996/May/12 */ spreadxoffsetsvd = spreadxoffset; spreadyoffsetsvd = spreadyoffset; spreadwantedzoomsvd = spreadwantedzoom; if (! bFirstInst) { /* for secondary DVIWindo's ? 95/May/5 */ (void) GetPrivateProfileString(achPr, "NotFirstMapping", "", str, sizeof(str), achFile); if (*str != '\0') sscanf(str, "%ld %ld %d", &pagexoffset, &pageyoffset, &pagewantedzoom); } /* xoffset = pagexoffset; yoffset = pageyoffset; wantedzoom = pagewantedzoom; */ setoffsetandzoom(1); /* 1996/May/12 */ (void) GetPrivateProfileString(achPr, "Defaults", "", str, sizeof(str), achFile); if (*str != '\0') splitupdefaults(str, DefPath, DefSpec, DefExt); (void) GetPrivateProfileString(achPr, "FileName", "", str, sizeof(str), achFile); /* if (strlen(str) < MAXFILENAME) strcpy(OpenName, str); */ if (strlen(str) < sizeof(OpenName)) strcpy(OpenName, str); (void) GetPrivateProfileString(achPr, "SourceFileName", "", SourceOpenName, sizeof(SourceOpenName), achFile); /* 93/Dec/8 */ (void) GetPrivateProfileString(achPr, "SourceDefaults", "", str, sizeof(str), achFile); if (*str != '\0') splitupdefaults(str, SourceDefPath, SourceDefSpec, SourceDefExt); /* worry about exceeding MAXFACENAME limits ? */ (void) GetPrivateProfileString(achPr, "Font", "", TestFont, sizeof(TestFont), achFile); /* Font Size used in Sample Font Display */ /* 95/Jan/10 */ TestSize = GetPrivateProfileInt(achPr, "TestSize", 20 * 20, achFile); /* Retrieve Filter Indeces for DVI and TeX File Open Dialogs 95/July/6 */ GetPrivateProfileString(achPr, "Filters", "", str, sizeof(str), achFile); if (*str != '\0') sscanf (str, "%lu %lu", &DVIFilterIndex, &TeXFilterIndex); /* if (DVIFilterIndex > 3) DVIFilterIndex = 1; */ if (DVIFilterIndex > 4) DVIFilterIndex = 1; if (TeXFilterIndex > 5) TeXFilterIndex = 1; (void) GetPrivateProfileString(achPr, "AuxWinPos", "", str, sizeof(str), achFile); if (*str != '\0') /* 94/Mar/21 */ sscanf (str, "%d %d %d %d", &UsedxLeft, &UsedyTop, &InfoxLeft, &InfoyTop); (void) GetPrivateProfileString(achPr, "ConsoleSize", "", str, sizeof(str), achFile); if (*str != '\0') sscanf (str, "%d %d %d %d", &CxLeft, &CyTop, &CcxWidth, &CcyHeight); (void) GetPrivateProfileString(achPr, "QuerySize", "", str, sizeof(str), achFile); if (*str != '\0') sscanf (str, "%d %d %d %d", &QxLeft, &QyTop, &QcxWidth, &QcyHeight); /* read units for ruler */ (void) GetPrivateProfileString(achPr, "Units", "pt", str, sizeof(str), achFile); for (k = 0; k < 32; k++) { if (strcmp(unitnames[k], "") == 0) { units = 1; break; } /* default - pt */ if (strcmp(unitnames[k], str) == 0) { units = k; break; } } if (units == 9) pcptflag = 1; else pcptflag = 0; bPauseCalls = GetPrivateProfileInt(achEnv, "DEBUGPAUSE", bPauseCalls, achFile); bPreferKnown = 1; } // returns 0 if working directory exists // now returns 1 if working directory exists int CheckWorking(char *WorkDir) { /* check working directory */ int flag=0; UINT DriveType; char drive[MAXPATHLEN]; char *s; #ifdef DEBUGMAIN if (bDebug > 1) OutputDebugString("Check WorkingDirectory\n"); #endif if ((s = strchr(WorkDir, ':')) != NULL) { strncpy(drive, WorkDir, s - WorkDir + 1); *(drive + (s - WorkDir + 1)) = '\0'; strcat(drive, "\\"); DriveType = GetDriveType (drive); if (DriveType == 0) flag = 1; /* no drive installed there */ } /* if (*(WorkDir+1) == ':') { c = *WorkDir; if (c >= 'a' && c <= 'z') c = c - 'a'; else if (c >= 'A' && c <= 'Z') c = c - 'A'; DriveType = GetDriveType (c); if (DriveType == 0) flag = 1; } */ /* else winerror("Specify Drive in Working Directory"); */ if (flag == 0) { if (ChangeDirectory(WorkDir, 0) != 0) flag = 1; } if (flag) { sprintf(str, "Working Directory `%s' not valid", WorkDir); winerror(str); } return (flag == 0); } /* attempts to split into executable and command line args */ /* str contains executable null delimited, if any */ /* returns pointer to command line args (possible the whole thing) */ char *extractcall (char *str) { /* 1995/June/26 */ char *s, *t; /* dvipsone.bat -v -b=1 -e=3 for example */ /* d:\dvisourc\dvipsont for example */ if (*str == '-') return str; /* command line flag, no executable */ else if ((s = strchr(str, '.')) == NULL) return str; /* is safety escape 95/Sep/12 */ t = str; while (*t > ' ') t++; /* to white space or end of string */ if (s > t) return str; /* if '.' comes after white space */ /* if (s != NULL && s < t) */ /* does '.' occur before white space */ /* if (s < t) */ /* does '.' occur before white space ? */ if (*t != '\0') *t++ = '\0'; /* split into two parts at white space */ /* careful if nothing follows ... */ #ifdef DEBUGEXTRACT if (bDebug > 1) { sprintf(debugstr, "%s %s", str, t); OutputDebugString(debugstr); } #endif /* WARNING: TAKE OUT AGAIN! */ return t; } /* *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** */ /* New way of organizing the reading of [Window] section of DVIWINDO.INI */ typedef struct { char *name; int *value; } FLAGSTRUCT; FLAGSTRUCT Flags[] = { {"BGR", &bBGRflag}, /* flip color order if it is an error */ {"Remap", &bATMBugFlag}, /* turn off remapping / or forcing it always on */ {"Share", &bUseTimer}, /* provides a way of turning off timer */ {"PreventConflict", &bPreventConflict}, /* Stop WM_PAINT while WinExec runs */ {"Offset", &bUseNewPageOffset}, /* revert to old page top scheme */ {"UseRect", &bUseRect}, /* use alternate rectangle filling */ {"ShowName", &bShowFileName}, /* turn off EPSF/TIFF name if no preview */ {"ShowImage", &bShowImage}, /* turn off reading of TIFF image file */ {"HyperText", &bHyperText}, /* turn off hyper text capability */ {"QuickLink", &bQuickLink}, /* work around QuickLink II FAX/MODEM bug */ {"Screen", &bUseMagicScreen}, /* force use of nice halftone screen */ {"TTRemap", &bTTRemap}, /* remap 0 -- 31 in TrueType fonts */ {"TTOnly", &bTrueTypeOnly}, /* allow only TrueType fonts */ {"T1Only", &bTypeOneOnly}, /* allow only Adobe Type 1 fonts */ {"PatchBadTTF", &bPatchBadTTF}, /* `text' TTF fonts that aren't 98/Sep/25 */ {"Aspect", &bAspectKeep}, /* zoom rectangle aspect ratio maintenance */ {"ANSITeX", &bANSITeXFlag}, /* remapping of low end of ANSI fonts */ {"Escape", &bEscapeEnable}, /* Escape key exits DVIWindo (use Alt-F4) */ {"Alternate", &bOddEven}, /* select new odd/even alternate page print */ /* {"CommDlg", &bAllowCommDlg}, */ /* use COMMDLG.DLL for main open dialog */ {"CommFind", &bNewSearch}, /* use CommDlg `Find' Dialog box */ {"TTFontSection", &bTTFontSection}, /* look at [TTFonts] of WIN.INI */ {"IgnoreBadEncoding", &bIgnoreBadANSI}, /* ignore check for bad ANSI */ {"IgnoreBadInstall", &bIgnoreBadInstall}, /* ignore TT font name errors */ {"Deslash", &bUnixify}, /* use slash instead backslash in TeX Menu */ {"CmdShow", &nCmdShowForce}, /* -1 of CmdShow for WinExec 94/Mar/8 */ {"PaletteOffset", &nPaletteOffset}, /* offset to palette index 94/Mar/9 */ {"MaxBright", &nMaxBright}, /* max color bright in fonts 94/Mar/9 */ {"ColorStable", &bColorStable}, /* color depends TeX font number 94/Mar/10 */ {"FontMap", &bTeXFontMap}, /* allow use of texfonts.map alias 94/Mar/18 */ {"SmallStep", &bSmallStep}, /* small magnification increments 94/Apr/19 */ {"SciWord", &bSciWord}, /* Scientific Word Figure Inc 94/Apr/21 */ {"SnapTo", &bSnapToFlag}, /* Snapto rule coordinates 94/July/6 */ {"RefreshDelay", &nRefreshDelay}, /* control delay after change 94/Aug/10 */ {"ISOTROPIC", &bISOTROPIC}, /* WMF output marked ISOTROPIC 94/Oct/4 */ {"IgnoreFontCase", &bIgnoreFontCase}, /* Ignore font name case 94/Oct/29 */ {"IgnoreLigatures", &bIgnoreLigatures}, /* Step over ligs search 94/Oct/29 */ {"ATMPrefer", &bATMPrefer}, /* Prefer Type 1 fonts 94/Dec/22 */ {"ATMExactWidth", &bATMExactWidth}, /* Force correct width 94/Dec/22 */ {"AvoidFlood", &bAvoidFlood}, /* Avoid FloodFill 94/Dec/22 */ {"UseGetProfileATM", &bUseGetProfileATM}, /* GetProfile ATM.INI 95/Jan/12 */ {"UseGetProfileTT", &bUseGetProfileTT}, /* GetProfile WIN.INI 95/Jul/12 */ {"UseTTMapping", &bUseTTMapping}, /* Use mapping table 95/Jul/12 */ {"AllowVersion", &bAllowVersion}, /* last char mismatch 95/Jul/30 */ {"AllowTruncate", &bAllowTruncate}, /* allow TFM name trunc 95/Aug/27 */ {"ClipRules", &bClipRules}, /* Clip rules to Window 95/Aug/26 */ {"FixZeroWidth", &bFixZeroWidth}, /* Zero Width RectVisible 95/Aug/30 */ {"UseATMINI", &bUseATMINI}, /* Use ATM.INI to look for T1 fonts */ {"UseTTFINI", &bUseTTFINI}, /* Use WIN.INI to look for TT fonts */ {"UseUSRINI", &bUseUSRINI}, /* Use .FNT for fonts */ {"UseTEXINI", &bUseTEXINI}, /* Use DVIWINDO.FNT for fonts */ {"PassSize", &bPassSize}, /* Pass paper size to DVIPSONE 95/Jun/22 */ {"PassOrient", &bPassOrient}, /* Pass landscape orient DVIPSONE 95/Jun/24 */ {"PassDuplex", &bPassDuplex}, /* Pass duplex to DVIPSONE 96/Nov/17 */ {"TraceCurveto", &bTraceCurveto}, /* Trace Curveto in MakeAFM 95/Jun/24 */ {"UseRegistry", &bUseRegistryFile}, /* Use ttfonts.reg Windows 95 95/Aug/15 */ {"UseRegEnumValue", &bUseRegEnumValue}, /* Use RegEnumValue Windows 95 */ {"StringLimit", &StringLimit}, /* Limit on string accumulation TextOut */ {"MagBase", &magbase}, /* base of magnification steps */ {"Frequency", &ScreenFrequency}, /* halftone screen frequency */ {"Angle", &ScreenAngle}, /* halftone screen angle */ {"MinWidth", &MinWidth}, /* min rect width RectVisible 95/Sep/3 */ {"ForceTIFF", &bForceTIFF}, /* force .tif file for .eps 95/Sep/7 */ {"MaxDocuments", &nMaxDocuments}, /* remembered files 95/Sep/17 */ {"HelpAtEnd", &bHelpAtEnd}, /* Help menu on right 95/Sep/17 */ {"UseGetExtent", &bUseGetExtent}, /* GetExtent for Char Widths 95/Nov/5 */ {"CommFont", &bCommFont}, /* use CommDlg `Font' Dialog box */ {"LongNames", &bLongNames}, /* show long names in dialog box */ {"KeepPrinterDC", &bKeepPrinterDC}, /* 1995/Dec/14 */ {"KeepDEVMODE", &bKeepDEVMODE}, /* 1996/July/7 */ {"UseDevModeCopies", &bUseDevModeCopies}, /* 1995/Dec/15 */ /* {"CommPrint", &bCommPrint}, */ /* use CommDlg `Print' Dialog 96/Jan/7 */ /* {"UsePalette", &bUsePalette}, */ /* 1996/March/24 */ /* {"UseFakeFont", &bUseFakeFont}, */ /* 1996/March/31 */ {"DefaultTIFFDPI", &nDefaultTIFFDPI}, /* 1996/Apr/3 */ {"AutoActivate", &bAutoActivate}, /* 1996/May/28 may be overridden ? */ {"KeepZeroKern", &bKeepZero}, /* 1996/July/28 */ {"UseBaseFont", &bUseBaseFont}, /* 1996/July/30 */ {"RawSpecial", &bAllowAndrew}, /* 1996/Aug/22 */ {"CompressColor", &bCompressColor}, /* 1996/Sep/7 */ {"StretchGray", &bStretchGray}, /* 1996/Sep/15 */ {"StretchColor", &bStretchColor}, /* 1996/Sep/15 */ {"ATM4", &bATM4}, /* 1996/June/3 overridden ??? */ {"StripPath", &bStripPath}, /* 1996/Oct/4 */ {"NoScriptSel", &bNoScriptSel}, /* 1996/Oct/28 */ {"WarnOnce", &bT1WarnOnce}, /* 1996/Nov/29 */ {"NewShell", &bNewShell}, /* 1996/Nov/29 */ {"UseATMFontInfo", &bUseATMFontInfo}, /* 1996/July/28 */ #ifdef AllowCTM {"AdvancedGraphics", &bUseAdvancedGraphics}, /* 1996/Nov/3 */ {"UseCTM", &bUseCTMflag}, /* 1996/Nov/6 */ #endif #ifdef USEUNICODE {"NewEncodeTT", &bUseNewEncodeTT}, /* 97/Jan/16 */ {"NewEncodeT1", &bUseNewEncodeT1}, /* 97/Jan/16 */ {"OldLigCodes", &bOldUnicode}, /* 97/Feb/16 */ #endif {"Decorative", &bDecorative}, /* 97/Feb/9 */ {"DontCare", &bDontCare}, /* 97/Feb/16 */ {"UseSharedName", &bUseSharedName}, /* 97/Feb/24 */ {"CopyInfo", &bInfoToClip}, /* 97/July/12 */ {"IgnoreRemapped", &bIgnoreRemapped}, /* 97/Sep/11 */ {"FontScale", &nMagicFact}, /* 97/Sep/14 */ {"UpperCase", &bUpperCase}, /* 97/Oct/21 */ {"AvoidZeroWidth", &bAvoidZeroWidth}, /* 98/Jan/12 */ {"OffsetRule", &bOffsetRule}, /* 98/Jan/12 */ {"CarryColor", &bCarryColor}, /* 98/Feb/14 */ {"FlipRotate", &bFlipRotate}, /* 98/Feb/28 */ {"AltHomeEnd", &bAltHomeEnd}, /* 98/Jun/30 */ {"AllowClip", &bAllowClip}, /* 98/Sep/10 */ /* {"LinkToEditor", &bSynchronicity}, */ /* 98/Nov/5 */ {"DDEServer", &bDDEServer}, /* 98/Dec/12 */ {"DrawOutline", &bDrawOutline}, /* 99/Jan/20 */ {"ForceCharSpacing", &bForceCharSpacing}, /* 99/Mar/4 */ {"ShowFullName", &bShowFullName}, /* 99/Apr/21 */ {"MultiInstance", &bMultiInstance}, /* 99/May/31 */ {"GutterOffset", &GutterOffset}, /* 00/Jan/09 */ {"UseBase13", &bUseBase13}, /* 00/May/24 */ {"QuoteAtSign", &bQuoteAtSign}, /* 00/May/27 */ {"ConvertUnderScores", &bConvertUnderScores}, /* 00/Jul/4 */ {"AllowFontNames", &bAllowFontNames}, /* 00/Jul/4 */ // {"AFMtoTFMDLL", &bUseAFMtoTFMDLL}, /* 99/June/13 */ // {"DVIPSONEDLL", &bUseDVIPSONEDLL}, /* 99/June/13 */ // {"YANDYTEXDLL", &bUseYandYTeXDLL}, /* 99/June/13 */ // {"CallBackPass", &bCallBackPass}, /* 99/July/20 */ // {"ConsoleOpen", &bConsoleOpen}, /* 99/July/23 */ {"", NULL} }; /* {"RememberDocs", &bRememberDocs}, */ /* Remember files opened 95/Sep/17 */ /* {"AllowBadBox", &bAllowBadBox}, */ /* Allow % in %% comments 94/Aug/19 */ /* {"ShowViewPort", &bShowViewPort}, */ /* Show WMF ViewPort 94/Oct/5 */ /* {"ShowMetaFile", &bShowMetaFile}, */ /* show WMF insertions 94/Oct/1 */ /* {"ShowTIFF", &bShowTIFF}, */ /* show TIFF insertimage: 97/Jan/5 */ /* {"MapMode", &nMapMode}, */ /* 1996/Aug/1 */ /* Read in PrivateProfileInt's using the above table */ void GetPrivateIntegers (void) { int k; /* int n; */ if (achFile == NULL) return; for (k = 0; k < 1024; k++) { if (*Flags[k].name == '\0' || Flags[k].value == NULL) break; *Flags[k].value = (int) GetPrivateProfileInt(achPr, Flags[k].name, *Flags[k].value, achFile); } } void FreeCommandStrings(void) { if (szDVIPSONE != NULL) { free(szDVIPSONE); szDVIPSONE = NULL; } if (szDVIDistiller != NULL) { free(szDVIDistiller); szDVIDistiller = NULL; } if (szDVIPSONEcom != NULL) { free(szDVIPSONEcom); szDVIPSONEcom=NULL; } if (szAFMtoTFM != NULL) { free(szAFMtoTFM); szAFMtoTFM = NULL; } if (szAFMtoTFMcom != NULL) { free(szAFMtoTFMcom); szAFMtoTFMcom = NULL; } if (szYandYTeX != NULL) { free(szYandYTeX); szYandYTeX = NULL; } if (szYandYTeXcom != NULL) { free(szYandYTeXcom); szYandYTeXcom = NULL; } } /* May now be used to reset command line strings */ /* Separated out since can be changed from menu now 97/Apr/3 */ void SetCommandStrings (void) { char *t; FreeCommandStrings(); if (achFile == NULL) return; /* Command line string to pass to DVIPSONE */ GetPrivateProfileString(achPr, "DVIPSONE", "", str, sizeof(str), achFile); /* 1994/Mar/7 */ /* Provide for possibility of calling something other than "DVIPSONE" */ if (*str != '\0') { t = extractcall (str); szDVIPSONE = zstrdup(t); /* 95/July/15 */ if (t > str) szDVIPSONEcom=zstrdup(str); /* 95/July/15 */ } #ifdef DEBUGMAIN if (bDebug > 1 && szDVIPSONE != NULL) OutputDebugString(szDVIPSONE); #endif /* Command line string to pass to DVIPSONE/Distiller */ /* 99/Dec/30 */ GetPrivateProfileString(achPr, "DVIPSONE/Distiller", "", str, sizeof(str), achFile); /* Provide for possibility of calling something other than "DVIPSONE" */ if (*str != '\0') { t = extractcall (str); szDVIDistiller = zstrdup(t); // if (t > str) szDVIPSONEcom=zstrdup(str); } #ifdef DEBUGMAIN if (bDebug > 1 && szDVIDistiller != NULL) OutputDebugString(szDVIDistiller); #endif /* Command line string to pass to AFMtoTFM */ GetPrivateProfileString(achPr, "AFMtoTFM", "", str, sizeof(str), achFile); /* 1995/June/26 */ /* Provide for possibility of calling something other than "AFMtoTFM" */ if (*str != '\0') { t = extractcall (str); szAFMtoTFM = zstrdup(t); if (t > str) szAFMtoTFMcom = zstrdup(str); /* 95/July/15 */ } #ifdef DEBUGMAIN if (bDebug > 1 && szAFMtoTFM != NULL) OutputDebugString(szAFMtoTFM); #endif /* Command line string to pass to TeX */ GetPrivateProfileString(achPr, "TeX", "", str, sizeof(str), achFile); /* 94/July/10 */ /* Provide for possibility of calling something other than "TeX" ??? */ if (*str != '\0') { t = extractcall (str); szYandYTeX = zstrdup(str); /* 95/July/15 */ if (t > str) szYandYTeXcom = zstrdup(str); } #ifdef DEBUGMAIN if (bDebug > 1 && szYandYTeX != NULL) OutputDebugString(szYandYTeX); #endif } /* Need to be able to refresh strings from env vars 98/Dec/24 */ /* Alternative: read all env vars right before use only */ void ReadEnvVars (void) { /* 98/Dec/24 */ int count; char *s, *t; if (achFile == NULL) return; /* Information to communicate with editor via DDE */ /* EditorDDE=Application;Topic;"+%d %s";... */ /* Here ; replaced with null */ /* Use %; to get ; */ GetPrivateProfileString(achEnv, "EditorDDE", "", str, sizeof(str), achFile); /* 1998/Nov/5 */ count = 0; if (*str != '\0') { strcat(str, " "); /* dummy replaced by null at the end */ if (szEditorDDE != NULL) free(szEditorDDE); /* 98/Dec/24 */ szEditorDDE = zstrdup(str); s = szEditorDDE; while ((t = strchr(s, ';')) != NULL) { if (t == str || *(t-1) != '%') { /* %; quotes ; */ *t = '\0'; /* replace ; with null */ count++; } t++; s = t; } s += strlen(s); *(s-1) = '\0'; /* replace dummy by null so there are two nulls */ } if (count < 2) { /* need Application,Topic,String */ free(szEditorDDE); szEditorDDE = NULL; } GetPrivateProfileString(achEnv, "TeXEdit", "", str, sizeof(str), achFile); /* 1998/Nov/5 */ if (*str != '\0') { if (szTeXEdit != NULL) free(szTeXEdit); /* 98/Dec/24 */ szTeXEdit = zstrdup(str); } // CustomPageSize=612bp*792bp // GetPrivateProfileString(achEnv, "CustomPaperSize", "", str, // sizeof(str), achFile); // 2000 May 27 // if (*str != '\0') // (void) decodepapersize(str, &CustomPageWidth, &CustomPageHeight); // non-zero values tell it there is a custom size defined } void ReadPaths (void) { if (achFile == NULL) return; /* YANDYPATH unlikely to change! */ (void) GetPrivateProfileString(achEnv, "YANDYPATH", "", str, sizeof(str), achFile); if (*str != '\0') { if (szBasePath != NULL) free(szBasePath); szBasePath = zstrdup(str); } /* DVIPATH rarely used ... */ (void) GetPrivateProfileString(achEnv, "DVIPATH", "", str, sizeof(str), achFile); /* if (*str != '\0') DefPath = _strdup(str); */ /* NO */ if (*str != '\0') { strncpy(DefPath, str, sizeof(DefPath)-2); strcat(DefPath, "\\"); } (void) GetPrivateProfileString(achEnv, "VECPATH", "", str, sizeof(str), achFile); if (*str != '\0') { if (szVecPath != NULL) free(szVecPath); szVecPath = zstrdup(str); } (void) GetPrivateProfileString(achEnv, "PREPATH", "", str, sizeof(str), achFile); if (*str != '\0') { if (szPrePath != NULL) free(szPrePath); szPrePath = zstrdup(str); } (void) GetPrivateProfileString(achEnv, "PSPATH", "", str, sizeof(str), achFile); if (*str != '\0') { if (szEPSPath != NULL) free(szEPSPath); szEPSPath = zstrdup(str); } (void) GetPrivateProfileString(achEnv, "TEXDVI", "", str, sizeof(str), achFile); if (*str != '\0') { if (szTeXDVI != NULL) free(szTeXDVI); szTeXDVI = zstrdup(str); } /* following moved elsewhere to allow for encoding changes */ /* (void) GetPrivateProfileString(achEnv, "TEXFONTS", "", str, sizeof(str), achFile); */ /* if (*str != '\0') TeXFonts = zstrdup(str); */ } /* Read in those `preferences' controlled only from dviwindo.ini file */ /* (these come from the [Window] section of dviwindo.ini */ void ReadFixedPrefer (void) { /* read those things that are not saved */ char *s; int n; if (achFile == NULL) return; // Allow specification working directory (override when DVIWindo starts up) // Use DVIWindo `Working Directory' in `Preview' from `TeX' menu bUseWorkPath = 0; bUseSourcePath = 1; /* default ??? */ (void) GetPrivateProfileString(achPr, "WorkingDirectory", "", str, sizeof(str), achFile); // special case test indicating there is *no* WorkingDirectory 94/Jan/21 if (_stricmp(str, "nul") == 0 || _stricmp(str, "null") == 0) *str = '\0'; // Set `UseWorkPath' and reset `UseSourcePath' // if (*str != '\0' && strlen(str) < sizeof(IniDefPath)) if (*str != '\0') { // strcpy(IniDefPath, str); s = str + strlen(str) - 1; if (*s != '\\' && *s != '/') strcat(s, "\\"); // bUseWorkPath = 1; bUseSourcePath = 0; // CheckWorking(IniDefPath); // if (CheckWorking(s) == 0) { /* 95/Mar/18 */ if (CheckWorking(str)) { /* 95/Mar/18 */ if (IniDefPath != NULL) free(IniDefPath); IniDefPath = zstrdup(str); bUseWorkPath = 1; bUseSourcePath = 0; bWorkingExists = 1; } } /* allow choice of colors for borders */ (void) GetPrivateProfileString(achPr, "BorderColor", "", str, sizeof(str), achFile); sscanf (str, "%d %d %d", &RBorderPen, &GBorderPen, &BBorderPen); /* allow choice of colors for liners */ (void) GetPrivateProfileString(achPr, "LinerColor", "", str, sizeof(str), achFile); sscanf (str, "%d %d %d", &RLinerPen, &GLinerPen, &BLinerPen); /* allow choice of colors for figures */ (void) GetPrivateProfileString(achPr, "FigureColor", "", str, sizeof(str), achFile); sscanf (str, "%d %d %d", &RFigurePen, &GFigurePen, &BFigurePen); /* Allow user to customize hot key for Preview */ /* 1994/Jan/22 */ GetPrivateProfileString(achPr, "PreviewHotKey", szPreviewHotKey, szPreviewHotKey, sizeof(szPreviewHotKey), achFile); /* SetCommandStrings() */ /* used to be inline here */ /* Specify name of registry dump file (Windows 95) */ GetPrivateProfileString(achPr, "RegistryFile", "", str, sizeof(str), achFile); /* 95/Aug/1 */ /* If user specifies a file name for the registry file, ... */ /* then always call RegEdit ahead of time (not after TT fonts not found) */ if (*str != '\0') { szRegistry = zstrdup(str); /* 95/Aug/1 */ /* *IF* user specified file to write to 95/Aug/18 */ /* always write ttfonts.reg ahead of time */ /* if (bWin95) bAlwaysWriteReg = 1; */ if (bNewShell) { bAlwaysWriteReg = 1; /* bNewShell 96/Oct/2 */ bUseRegistryFile = 1; /* 96/Nov/30 */ } } /* else if (bWin95) szRegistry="ttfonts.reg"; */ /* default 95/Aug/16 */ else if (bNewShell) /* szRegistry="ttfonts.reg"; */ /* default 95/Aug/16 */ szRegistry = zstrdup("ttfonts.reg"); /* 98/Dec/25 */ /* if (*szRegistry == '\0') *//* don't try and use registry file */ if (szRegistry == NULL) bUseRegistryFile = 0; /* if there is no file name */ /* Specify what ports `Use DVIPSONE' should be checked for */ GetPrivateProfileString(achPr, "UseDVIPSONE", "", str, sizeof(str), achFile); if (*str == '\0') { GetPrivateProfileString(achPr, "DVIPSONEport", "", str, sizeof(str), achFile); } if (*str != '\0') { /* if it's not zero or one, it must be a port name */ if (sscanf(str, "%d", &bUseDVIPSONE) == 0) { /* szDVIPSONEport = _strdup(str); */ /* 94/June/3 */ if (szDVIPSONEport != NULL) free(szDVIPSONEport); szDVIPSONEport = zstrdup(str); /* 95/July/15 */ if (strstr(szDVIPSONEport, "BOGUS") != NULL) bUseDVIPSONE = 0; /* 97/May/3 */ else bUseDVIPSONE = 1; } } #ifdef DEBUGEXTRACT /* if (bUseDVIPSONE != 0) */ if (bUseDVIPSONE != 0 && szDVIPSONEport != NULL) { if (bDebug > 1) { sprintf(debugstr, "szDVIPSONEport=%s", szDVIPSONEport); OutputDebugString(debugstr); } } /* WARNING: TAKE OUT AGAIN! */ #endif /* ReadEnvVars(); */ /* split off 98/Dec/24 */ /* Control mode in which OpenFile happens */ /* 0 COMPAT, 1 EXCLUSIVE, 2 DENY_WRITE, 3 DENY_READ, 4 DENY_NONE */ n = (int) GetPrivateProfileInt(achPr, "OpenCode", -1, achFile); if (n >= 0 && n < 5) OfShareCode = n << 4; /* else OfShareCode = OF_SHARE_DENY_WRITE; */ /* leave at default */ n = (int) GetPrivateProfileInt(achPr, "ExistCode", -1, achFile); if (n >= 0 && n < 5) OfExistCode = n << 4; /* else OfExistCode = OF_SHARE_DENY_NONE; */ /* leave at default */ GetPrivateIntegers(); /* read loads of 'em */ /* fix ups, sanity checks and such: */ if (magbase < 100) magbase = 100; /* sanity check */ if (magbase > 10000) magbase = 10000; /* sanity check */ if (StringLimit < 0) StringLimit = 1; else if (StringLimit == 0) StringLimit = MAXCHARBUF; else if (StringLimit > MAXCHARBUF) StringLimit = MAXCHARBUF; /* if (bWin95 == 0) */ /* ignore except in Windows 95 */ if (bNewShell == 0) { /* changed 96/Oct/2 */ bUseRegistryFile = 0; bUseRegEnumValue = 0; /* ??? */ /* bAutoActivate = 0; */ /* need ATM 4.0 for this */ } if (nMaxDocuments <= 0) { // should not happen // wininfo("No Documents to Remember"); debugging only bRememberDocs = 0; } else if (nMaxDocuments > 9) nMaxDocuments = 9; /* if (bRememberDocs) filldocmenu(hwnd); */ /* ??? */ /* SetCommandStrings(); */ /* moved here 97/Apr/3 */ } /* come here when exiting secondary DVIWindo with Save Preferences not set */ void WriteNotFirst (void) { /* 1995/Apr/25 */ if (achFile == NULL) return; if (cxWidth==0) cxWidth = CW_USEDEFAULT; if (cxWidth > 200 && cyHeight > 100) { /* avoid iconized lossage */ /* sprintf(str, "%d %d %d %d", xLeft, yTop, cxWidth, cyHeight); */ sprintf(str, "%d %d %d %d %d", xLeft, yTop, cxWidth, cyHeight, bMaximized); (void) WritePrivateProfileString(achPr, "NotFirstSize", str, achFile); } /* record screen mapping and position for secondary DVIWindo's 95/May/5 */ sprintf(str, "%ld %ld %d", pagexoffset, pageyoffset, pagewantedzoom); (void) WritePrivateProfileString(achPr, "NotFirstMapping", str, achFile); } void WriteTime (char *achSection, char *szKey) { char *s, *send; time_t ltime; /* for time and date */ if (achFile == NULL) return; (void) time(<ime); /* get seconds since 1970 */ if (ltime < 0) return; /* sanity check 98/Jul/20 */ s = ctime(<ime); if (s == NULL) return; /* sanity check 96/Jan/6 */ lcivilize(s); /* if ((send = strchr(s, '\n')) != NULL) *send = '\0'; */ /* 1995/Jan/22 */ send = s + strlen(s) - 1; /* 1995/Mar/15 */ while (send > s && *send <= ' ') *send-- = '\0'; // (void) WritePrivateProfileString(achPr, "LastTime", s, achFile); // (void) WritePrivateProfileString(achPr, szKey, s, achFile); // (void) WritePrivateProfileString(achDiag, szKey, s, achFile); (void) WritePrivateProfileString(achSection, szKey, s, achFile); } void WritePreferences (int flag) { /* write stuff to private profile file */ // char *s; /* time_t ltime; */ /* for time and date */ if (achFile == NULL) return; if (cxWidth==0) cxWidth = CW_USEDEFAULT; /* if (bSavePrefer == 0) return; */ /* 1993/March/16 */ if (bSavePrefer == 0 && flag == 0) return; /* 1995/April/22 */ /* if (bSavePrefer != 0) */ /* only if preferences are to be saved */ if (cxWidth > 200 && cyHeight > 100) { /* avoid iconized lossage */ /* sprintf(str, "%d %d %d %d", xLeft, yTop, cxWidth, cyHeight); */ sprintf(str, "%d %d %d %d %d", xLeft, yTop, cxWidth, cyHeight, bMaximized); (void) WritePrivateProfileString(achPr, "Size", str, achFile); } /* if (UsedxLeft != 0 || UsedyTop != 0 || UsedxLeft != 0 || UsedyTop != 0) */ if (UsedxLeft != 0 || UsedyTop != 0 || InfoxLeft != 0 || InfoyTop != 0) { sprintf(str, "%d %d %d %d", UsedxLeft, UsedyTop, InfoxLeft, InfoyTop); (void) WritePrivateProfileString(achPr, "AuxWinPos", str, achFile); } if (CcxWidth != 0 && CcyHeight != 0) { sprintf(str, "%d %d %d %d", CxLeft, CyTop, CcxWidth, CcyHeight); (void) WritePrivateProfileString(achPr, "ConsoleSize", str, achFile); } if (QcxWidth != 0 && QcyHeight != 0) { sprintf(str, "%d %d %d %d", QxLeft, QyTop, QcxWidth, QcyHeight); (void) WritePrivateProfileString(achPr, "QuerySize", str, achFile); } sprintf(str, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\ %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\ %d %d %d", bSpreadFlag, bCountZero, bLandScape, bGreyText, bGreyPlus, bColorFont, bRuleFillFlag, bShowBorder, bShowLiner, bResetScale, bShowBoxes, bCaseSensitive, bWrapFlag, bComplainMissing, bComplainSpecial, bIgnoreSpecial, bResetPage, bUseDVIPSONE, bPrintToFile, bPassThrough, papertype, bUseCharSpacing, bShowButtons, bReversePages, bTrueInch, bComplainFiles, bShowPreview, bCheckEncoding, bViewExtras, bDismissFlag, bShowViewPorts, bShowCalls, nDuplex, bShowTIFF, bShowWMF ); (void) WritePrivateProfileString(achPr, "Preferences", str, achFile); sprintf(str, "%d %d %d %d %d %d %d %d %d %d", bCallBackPass, bConsoleOpen, bOpenCloseChannel, bNewPassThrough, bForcePassBack, bDontAskFile, bOldPassThrough, bUseDLLs, bOpenClosePrinter, bUseFontName); (void) WritePrivateProfileString(achPr, "Preferences2", str, achFile); /* sprintf(str, "%ld %ld %d", xoffset, yoffset, wantedzoom); */ /* write page position and magnification */ sprintf(str, "%ld %ld %d", pagexoffset, pageyoffset, pagewantedzoom); (void) WritePrivateProfileString(achPr, "Mapping", str, achFile); /* write page position and magnification */ /* 96/Aug/26 */ sprintf(str, "%ld %ld %d", fontxoffset, fontyoffset, fontzoom); (void) WritePrivateProfileString(achPr, "FontMapping", str, achFile); /* write spread position and magnification 1996/May/12 */ if (spreadxoffset != pagexoffset || spreadyoffset != pageyoffset || spreadwantedzoom != pagewantedzoom) { sprintf(str, "%ld %ld %d", spreadxoffset, spreadyoffset, spreadwantedzoom); (void) WritePrivateProfileString(achPr, "SpreadMapping", str, achFile); } // winerror(DefPath); // debugging only // winerror(szWinDir); // debugging only /* avoid writing out incomplete path without drive - sanity check */ // if (strchr(DefPath, ':') == NULL) // if for some reason we don't have an absolute path... { sprintf(debugstr, "DefPath '%s' DefSpec '%s' DefExt '%s'\n", DefPath, DefSpec, DefExt); OutputDebugString(debugstr); // wincancel(debugstr); // debugging only } if (*DefPath == '\0') strcpy(DefPath, szWinDir); // avoid blank if (*DefSpec == '\0') strcpy(DefSpec, "*.dvi"); // avoid blank if (*DefExt == '\0') strcpy(DefExt, ".dvi"); // avoid blank if (strchr(DefPath, ':') == NULL && strncmp(DefPath, "\\\\", 2) != 0) strcpy(DefPath, szWinDir); /* just to write something! */ if (strchr(DefPath, ' ') != NULL) /* quote if spaces 97/Dec/10 */ sprintf(str, "\"%s\" %s %s", DefPath, DefSpec, DefExt); else sprintf(str, "%s %s %s", DefPath, DefSpec, DefExt); /* (LPSTR) DefPath, (LPSTR) DefSpec, (LPSTR) DefExt); */ (void) WritePrivateProfileString(achPr, "Defaults", str, achFile); /* sprintf(str, "%s", OpenName); */ /* (LPSTR) OpenName); */ strcpy(str, OpenName); /* 95/Dec/6 */ if (*str != '\0') (void) WritePrivateProfileString(achPr, "FileName", str, achFile); if (*SourceDefPath == '\0') strcpy(SourceDefPath, szWinDir);// avoid blank if (*SourceDefSpec == '\0') strcpy(SourceDefSpec, "*.tex"); // avoid blank if (*SourceDefExt == '\0') strcpy(SourceDefExt, ".tex"); // avoid blank /* avoid writing out incomplete path without drive - sanity check */ // if (strchr(SourceDefPath, ':') == NULL) // if for some reason we don't have an absolute path... if (strchr(SourceDefPath, ':') == NULL && strncmp(SourceDefPath, "\\\\", 2) != 0) strcpy(SourceDefPath, szWinDir); if (strchr(SourceDefPath, ' ') != NULL) /* quote if spaces 97/Dec/10 */ sprintf(str, "\"%s\" %s %s", SourceDefPath, SourceDefSpec, SourceDefExt); else sprintf(str, "%s %s %s", SourceDefPath, SourceDefSpec, SourceDefExt); if (*SourceOpenName != '\0') /* write only if used */ (void) WritePrivateProfileString(achPr, "SourceDefaults", str, achFile); if (*SourceOpenName != '\0') (void) WritePrivateProfileString(achPr, "SourceFileName", SourceOpenName, achFile); if (*TestFont != '\0') { (void) WritePrivateProfileString(achPr, "Font", TestFont, achFile); } // sprintf(str, "%d", TestSize); // (void) WritePrivateProfileString(achPr, "TestSize", str, achFile); (void) WritePrivateProfileInt(achPr, "TestSize", TestSize, achFile); /* if (StringLimit == MAXCHARBUF) { (void) WritePrivateProfileString(achPr, "StringLimit", NULL, achFile); } else { sprintf(str, "%d", StringLimit); (void) WritePrivateProfileString(achPr, "StringLimit", str, achFile); } */ /* remember Filter Indeces in File Open for DVI and TeX files */ sprintf(str, "%lu %lu", DVIFilterIndex, TeXFilterIndex); (void) WritePrivateProfileString(achPr, "Filters", str, achFile); /* write out units for measurement on `ruler' */ (void) WritePrivateProfileString(achPr, "Units", unitnames[units], achFile); // (void) WritePrivateProfileString(achPr, "Version", VERSION, achFile); (void) WritePrivateProfileString(achDiag, "Version", VERSION, achFile); /* following added 96/Sep/15 --- not needed 98/Dec/24 --- redundant */ (void) WritePrivateProfileString(achEnv, "DEBUGPAUSE", bPauseCalls ? "1" : NULL, achFile); if (bDebug) WriteTime(achDiag, "LastTime"); } /* save preferences if the phase of the moon is just right ... */ void maybesaveprefer (void) { if (bFlipSave != 0) { if (bSavePrefer != 0) bSavePrefer = 0; else bSavePrefer = 1; /* `temporary' flip bSavePrefer */ } /* Only save it if first instance and if not affected by Factory Default */ else if (bFirstInst != 0 && bFactory == 0) { // sprintf(str, "%d", bSavePrefer); // (void) WritePrivateProfileString(achPr, "Save", str, achFile); (void) WritePrivateProfileInt(achPr, "Save", bSavePrefer, achFile); } if (bDebug) { // sprintf(str, "%d", bFlipSave); // (void) WritePrivateProfileString(achDiag, "Flipped", str, achFile); (void) WritePrivateProfileInt(achPr, "Flipped", bFlipSave, achFile); } if (bSavePrefer) WritePreferences(0); /* write preferences */ else if (! bFirstInst) WriteNotFirst(); /* 95/Apr/25 */ } void TurnTimerOn (HWND hWnd) { int interval; /* if (bFloppyDisk != 0) winerror("Floppy"); */ if (bFloppyDisk == 0) interval = TICKTOCK; else interval = TICKTOCK * 8; /* 1992/Dec/19 */ bTimerOn = SetTimer(hWnd, 1, interval, NULL); nAlarmTicks = 0; /* 1994/Aug/10 */ } /* when launched with file name or drag&drop --- not anymore */ /* now used when printing from command line */ /* and in SwitchDVIFile from hypertext command */ void SetupFile (HWND hWnd, int invalidate) { int flag; char *s; bReadFile = 0; /* OK, we can reset this again now */ /* if (bDebug > 1) OutputDebugString(OpenName); */ // if file name relative, add current directory // if (strchr(OpenName, '\\') == NULL && // strchr(OpenName, '/') == NULL && // strchr(OpenName, ':') == NULL) if (IsRelative(OpenName)) { // 2000/March/15 (void) GetCurrentDirectory(sizeof(DefPath), DefPath); /* Will the following `DOS' code work in WIN32 ? */ /* getcwd(DefPath, MAXPATHLEN); */ /* if filename unqualified */ /* getcwd(DefPath, sizeof(DefPath)); *//* if filename unqualified */ /* _getcwd(DefPath, sizeof(DefPath)); */ s = DefPath + strlen(DefPath) - 1; /* 1995/Dec/18 */ if (*s != '\\' && *s != '/') strcat(DefPath, "\\"); /* if unqualified assume its in current directory - file manager interface */ } else { /* given qualified filename */ ParseFileName(); /* split OpenName into DefPath, DefSpec, DefExt */ strcpy(DefSpec, "*"); /* ??? */ strcat(DefSpec, DefExt); /* fix up DefSpec */ /* removeback(DefPath); */ /* 1993/Dec/9 */ ChangeDirectory(DefPath, 1); /* change directory and drive */ /* ChangeDirectory(DefPath, 0); */ /* 1996/Aug/26 trial */ /* trailingback(DefPath); */ /* 1993/Dec/9 */ } AddExt(OpenName, DefExt); hFile = DoOpenFile(hWnd); /* try and open file */ /* if (hFile >= 0) */ if (hFile != HFILE_ERROR) { /* dvipage = 1; */ /* not if called with command line arg */ flag = DoPreScan(hWnd, hFile); if (flag == 0) { if (bKeepFileOpen == 0) { /* if (hFile < 0) wincancel("File already closed"); */ if (hFile == HFILE_ERROR) (void) wincancel("File already closed"); /* if (_lclose(hFile) != 0) winerror("Unable to close file"); */ else _lclose(hFile); /* hFile = -1; */ hFile = HFILE_ERROR; } usepagetable(dvipage, 0); /* page is physical page */ bEnableTermination = 1; if (invalidate) /* 1995/April/30 */ InvalidateRect(hWnd, NULL, TRUE); if (bUseTimer != 0 && bTimerOn == 0) { TurnTimerOn(hwnd); /* bTimerOn = SetTimer(hwnd, 1, TICKTOCK, NULL); */ } } else { /* 1992/Apr/26 */ /* if (hFile < 0) wincancel("File already closed"); */ if (hFile == HFILE_ERROR) { /* (void) wincancel("File already closed"); */ sprintf(debugstr, "%s (%s)\n", "File already closed", "setupfile"); if (bDebug) { if (bDebug > 1) OutputDebugString(debugstr); else (void) wincancel(debugstr); } } /* if(_lclose(hFile) != 0) winerror("Unable to close file"); */ else _lclose(hFile); /* hFile = -1; */ hFile = HFILE_ERROR; closeup(hWnd, 1); /* safe ??? */ #ifdef HYPERFILE free_hyperfile(); /* right place ??? winsearc.c */ #endif } } } /* Extract device, driver, and port from command line string. Two formats: */ /* -w="Apple Laser Writer II NT",pscript,COM1: */ /* -w@Apple@Laser@Writer@II@NT,pscript,COM1: */ /* Latter first converted to: -w@Apple Laser Writer II NT,pscript,COM1: */ /* Could do some sanity checks on length, but what the hell ... */ /* if no arguments, then default printer will be used */ int analyzeprint(char *s) { /* try and extract device, driver, port */ int c, fakespace; char *t; /* We use these temporaray when using CommDlg */ /* char achPrinter[MAXPRINTERNAME]=""; */ char achDeviceTemp[MAXPRINTERNAME]=""; char achDriverTemp[MAXDRIVERNAME]=""; char achPortTemp[MAXPORTNAME]=""; int n, nlen; LPDEVNAMES lpDevNames; if (*s++ != 'w') return 0; /* shouldn't happen */ c = *s++; if (c == '\0') return 1; /* no arguments, will use default printer */ /* check whether using fake space character */ if (c != '=') { fakespace = c; t = s; /* first convert fake spaces to real spaces */ while ((c = *t++) >= ' ') if (c == fakespace) *(t-1) = ' '; } /* extract device name */ c = *s++; t = achDeviceTemp; /* or direct to achDevice ... */ if (c == '\"') { while ((c = *s++) != '\"' && c >= ' ') *t++ = (char) c; /* if (c == '\"') c = *s++; */ /* gobble the comma ? */ } else { *t++ = (char) c; while ((c = *s++) != ',' && c >= ' ') *t++ = (char) c; } *t = '\0'; if (c == '\0') return -1; /* run out of string ... */ /* extract driver name */ t = achDriverTemp; /* or direct to achDriver ... */ while ((c = *s++) != ',' && c >= ' ') *t++ = (char) c; *t = '\0'; if (c == '\0') return -1; /* run out of string ... */ /* extract port name */ t = achPortTemp; /* or direct to achPort ... */ while ((c = *s++) != ',' && c >= ' ') *t++ = (char) c; *t = '\0'; // can't have OLDPRINTDLG defined in WIN32... #ifdef IGNORED // #ifdef OLDPRINTDLG /* we have to copy temporary vales */ strcpy (achDevice, achDeviceTemp); strcpy (achDriver, achDriverTemp); strcpy (achPort, achPortTemp); #endif nlen = strlen(achDeviceTemp)+1 + strlen(achDriverTemp)+1 + strlen(achPortTemp)+1; pd.hDevNames = GlobalAlloc (GMEM_MOVEABLE, sizeof(DEVNAMES) + nlen); if (pd.hDevNames == NULL) { winerror ("Unable to allocate memory"); PostQuitMessage(0); /* pretty serious */ } lpDevNames = (LPDEVNAMES) GlobalLock(pd.hDevNames); n = sizeof(DEVNAMES); lpDevNames->wDriverOffset = (WORD) n; lstrcpy((LPSTR) (lpDevNames + n), achDeviceTemp); n += strlen(achDeviceTemp)+1; lpDevNames->wDeviceOffset = (WORD) n; lstrcpy((LPSTR) (lpDevNames + n), achDriverTemp); n += strlen(achDriverTemp)+1; lpDevNames->wOutputOffset = (WORD) n; lstrcpy((LPSTR) (lpDevNames + n), achPortTemp); n += strlen(achPortTemp)+1; GlobalUnlock(pd.hDevNames); /* link into PrintDlg structure */ /* GlobalFree (hDevNames); */ return -1; /* success (apparently) */ } int HasExtension (char *szFileName) { char *sdot, *slas; if ((sdot = strrchr(szFileName, '.')) == NULL) return 0; if ((slas = strrchr(szFileName, '\\')) != NULL && sdot < slas) return 0; if ((slas = strrchr(szFileName, '/')) != NULL && sdot < slas) return 0; return 1; } // Treat filenames with drive letters or ports as absolute (look for :) // Treat network file names as absolute (start with \\) int IsRelative (char *szFileName) { if (strchr(szFileName, ':') != NULL) return 0; if (strncmp(szFileName, "\\\\", 2) == 0) return 0; return 1; } /* Other Windows programs use /p or -p to ask for printing */ /* but we are already using that for something else ... */ int firstarg=1; /* index of first file name argument */ /* See MSJ, May 1991, page 136 for right way to use **__argv */ /* NOTE: argv[0] is always C:WIN486\system\KRNL386.EXE */ /* Use GetModuleFileName instead to get path to executable file */ /* GetModuleFileName(GetModuleHandle("dviwindo.exe"),filename,MAXFILENAME)*/ /* Following may need rework in UNICODE environment WIN32 */ /* Use GetCommandLine() in that case in winbase.h WIN32 */ int ReadCommandLine (int firstarg) { char *s, *send, *scol; int n; int k; if (bShowCommand) { s = str; sprintf(s, "Arguments:\n"); s = s + strlen(s); /* for (k = 1; k < __argc; k++) */ for (k = 0; k < __argc; k++) { if (s + strlen(__argv[k]) + 10 >= str + sizeof(str)) break; sprintf(s, "%2d:\t%s\n", k, __argv[k]); s = s + strlen(s); } (void) GetCurrentDirectory(sizeof(buffer), buffer); /* _getcwd(buffer, sizeof(buffer)); */ sprintf(s, "Current:\t%s\n", buffer); winerror(str); /* debugging ??? */ } /* bFileValid = 0; hClientWindow = NULL; */ /* sort of illogical to have this override saved default ... */ /* try and interpret command line arguments and command line flags */ // firstarg = 1; while (firstarg < __argc) { s = __argv[firstarg]; if (*s == '-' || *s == '/') { /* command line argument ? */ s++; /* flush the `-' or `/' */ if (*s == 'd') bDebug++; /* turn on debugging mode */ else if (*s == '1') bCallSelf++; /* pass call to other instance */ else if (*s == 's') { if ((*(s+1) == '\0') && (firstarg+1 < __argc)) { firstarg++; /* -s form */ s = __argv[firstarg]; /* go to next argument */ } else s++; /* s=... form, step over '=' */ if (sscanf(s, "%d%n", &nSourceLine, &n) == 1) { s += n; while (*s == ' ') s++; // ssrc = s; /* \special{src:...} source file name */ ssrc = zstrdup(s); /* \special{src:...} source file name */ bSearchCall++; /* it is a search call from editor */ } } else if (*s == 'p') { /* page number (screen) */ sscanf(s, "p=%d", &dvipage); nPageNum=dvipage; bPageCall++; /* 99/Jan/10 */ } else if (*s == 'w') /* request to print */ bPrintOnly = analyzeprint(s); /* else if (*s == 'j') bAllowVerbatim = 1; */ else if (*s == 'r') { /* 92/Sep/25 */ if (sscanf(s, "r=%d", &bReversePages) < 1) bReversePages=1; } #ifdef IGNORED else if (*s == 's') { /* steps to increment pages by */ if (sscanf(s, "s=%d", &pageincrement) < 1) pageincrement=2; bOddEven = 0; /* force old style for Sci Word ? 93/Sep/2 */ } #endif else if (*s == 'c') /* number of copies to print */ sscanf(s, "c=%d", &nCopies); else if (*s == 'b') /* begin page (print) */ sscanf(s, "b=%d", &beginpage); else if (*s == 'e') /* end page (print) */ sscanf(s, "e=%d", &endpage); else if (*s == 'g') { /* 1993/Aug/28 */ bOddOnly = 1; bOddEven = 1; /* in that case force new style */ } else if (*s == 'h') { /* 1993/Aug/28 */ bEvenOnly = 1; bOddEven = 1; /* in that case force new style */ } else if (*s == 'm') { /* client window */ sscanf(s, "m=%lu", &hClientWindow); } } else { /* not a command line argument - so must be filename */ /* strncpy(OpenName, __argv[k], MAXFILENAME); */ bReadFile = 1; /* (at least one) file name on command line */ // sdvi = __argv[firstarg]; /* save pointer 98/Dec/15 */ s = __argv[firstarg]; // new dealing with file relative to current directory 2000/Jan/11 if (IsRelative(s)) { // is it relative file name ? (void) GetCurrentDirectory(sizeof(str), str); send = str + strlen(str) - 1; if (*send != '\\' && *send != '/') strcat(str, "\\"); if (*s != '\\' && *s != '/') strcat(str, s); else if ((scol = strchr(str, ':')) != NULL) strcpy(scol+1, s); else strcat(str, s+1); } else strcpy(str, s); // force extension if none given 2000/Jan/12 if (! HasExtension(str)) strcat(str, DefExt); sdvi = zstrdup(str); if (strstr(sdvi, "dvi_help") != NULL) bReadHelp = 1; else bReadHelp = 0; /* 2000/Jan/5 */ // winerror(sdvi); // debugging only break; } firstarg++; } #ifdef DEBUGPRINT if (bPrintOnly != 0) { if (bDebug > 1) { sprintf(debugstr, "Device: %s Driver: %s Port: %s\n", achDevice, achDriver, achPort); OutputDebugString(debugstr); } } #endif #ifdef DEBUGCOMMAND sprintf(debugstr, "firstarg %d argc %d bDebug %d", firstarg, __argc, bDebug); OutputDebugString(debugstr); #endif return firstarg; } /* NOTE: we already have read preferences for file name etc */ /* but command line argument overrides this */ /* _getcwd(DefPath, sizeof(DefPath)); */ /* ParseFileName(); */ /* split OpenName into DefPath, DefSpec, DefExt */ /* strcpy(DefSpec, "*"); strcat(DefSpec, DefExt); *//* fix up DefSpec */ /* do we need to be showing the Window for SetupFile(0) to work ??? NO */ /* if(bReadFile != 0 && OpenName[0] != 0) SetupFile(hwnd); */ /* Above modified slightly to allow specification of multiple print files */ /* following is code for dealing with DEMO versions */ #ifdef ALLOWDEMO char *demowarn="WARNING: DEMO VERSION.\n"; char *months="JanFebMarAprMayJunJulAugSepOctNovDec"; /* 1994/June/8 */ int monthnumber(char *smonth) { int k; char *s=months; for (k = 0; k < 12; k++) { if (strncmp(smonth, s, 3) == 0) return k; s += 3; } return 0; /* Say what? */ } void stripcolon(char *s) { /* replace colons in time with spaces */ /* while (*s >= ' ') { if (*s == ':') *s = ' '; s++; } */ while ((s = strchr(s+1, ':')) != NULL) *s = ' '; } /* Owner is of form "Berthold K.P. Horn@100@1997 May 23 07:43:48\n" */ time_t checkdemo(char *owner) { /* now returns seconds since customized */ time_t ltime, otime; /* for date and time */ time_t dtime; /* seconds since customized */ struct tm loctim; int year, month, day; int hour, min, sec; char buffer[64]; char *s; #ifdef DEBUGINIT if (bDebug > 1) { OutputDebugString("Check DEMO\n"); OutputDebugString(str); /* ??? */ } #endif /* first calculate compilation time */ /* not used anymore */ /* sscanf(compiledate, "%s %d %d", buffer, &day, &year); */ s = owner; /* use customization time instead */ if (*s < ' ') return 0; /* uncustomized */ /* check that there are two occurences of @ - and step to date part */ if ((s = strchr(s+1, '@')) == NULL) return -1; if ((s = strchr(s+1, '@')) == NULL) return -1; #ifdef DEBUGINIT if (bDebug > 1) OutputDebugString(s+1); #endif stripcolon(s+1); if (sscanf(s+1, "%d %s %d %d %d %d", &year, buffer, &day, &hour, &min, &sec) < 6) { if (bDebug) winerror(s+1); /* should not happen */ return -1; } if (year > 1900) year = year - 1900; month = monthnumber(buffer); loctim.tm_year = year; loctim.tm_mon = month; loctim.tm_mday = day; #ifdef DEBUGINIT if (bDebug > 1) { sprintf(debugstr, "%d %d %d\n", year, month, day); OutputDebugString(debugstr); } #endif /* stripcolon(compiletime); */ /* extra fancy precision */ /* sscanf(compiletime, "%d %d %d", &hour, &min, &sec); */ /* not used */ loctim.tm_hour = hour; loctim.tm_min = min; loctim.tm_sec = sec; loctim.tm_isdst = -1; /* daylight saving time flag - info not avail */ #ifdef DEBUGINIT if (bDebug > 1) { sprintf(debugstr, "%d %d %d\n", hour, min, sec); OutputDebugString(debugstr); } #endif otime = mktime(&loctim); /* Note: mktime returns -1 for invalid input data */ /* This might be off by one hour (3600 sec) because of daylight savings */ (void) time(<ime); /* get seconds since 1970 */ /* Note: time() returns -1 if it can't get the time */ dtime = ltime - otime; /* time difference in sec so far */ if (bDebug > 1) { sprintf(debugstr, "dtime %ld = ltime %ld - otime %ld (%lg months)\n", dtime, ltime, otime, (double) dtime / (double) onemonth); OutputDebugString(debugstr); } if (dtime > onemonth * 12) { /* ExitWindows(EW_REBOOTSYSTEM, 0); */ /* Windows 3.1 */ ExitWindows(EW_RESTARTWINDOWS, 0); /* Windows 3.0 */ } return dtime; } #endif /* void showstackused(HWND hWnd, int flag) */ int showstackused(int flag) { /* 1994/June/21 */ char *s; int iPctOfStackUsed=0; if (flag == 0) wsprintf(debugstr, "DVIWindo %s ending --- ", (LPSTR) version); else *debugstr = '\0'; s = debugstr + strlen(debugstr); sprintf(s, "%d%% stack used", iPctOfStackUsed); if (flag) wininfo(str); /* show to user */ else if (bDebug > 1) { /* fixed 1995/July/10 */ OutputDebugString(debugstr); /* write % used in debug output */ } return iPctOfStackUsed; } char *convertnewlines (char *str) { char *s=str; while ((s = strchr(s, '\n')) != NULL) { if (*(s+1) == '\0') *s = '\0'; else *s = ' '; } return str; } void showtaggedchar (void) { if ((taggedchar > 32 && taggedchar < 127) || (taggedchar > 160 && taggedchar < 255)) sprintf(str, "Tag Char was %d (%c)", taggedchar, taggedchar); else sprintf(str, "Tag Char was %d ", taggedchar); wininfo(str); } void FreeATMTables (void) { int k; #ifdef ATMSOLIDTABLE if (hATMTable != NULL) hATMTable = GlobalFree(hATMTable); for (k = 0; k < MAXFONTS; k++) encodefont[k] = 0; // ??? #else for (k = 0; k < MAXFONTS; k++) if (hATMTables[k] != NULL) hATMTables[k] = GlobalFree(hATMTables[k]); #endif } void FreeColor (void); void freeall (void) { #ifdef HYPERFILE free_hyperfile(); /* in winsearc.c */ /* 95/Aug/12 */ #endif if (hFaceNames != NULL) FreeFaceNames(); if (hFullNames != NULL) (void) GlobalFree(hFullNames); /* 95/July/12 */ if (hFileNames != NULL) (void) GlobalFree(hFileNames); /* 95/July/12 */ hFaceNames = hFullNames = hFileNames = NULL; if (hWidths != NULL) (void) GlobalFree(hWidths); if (hPages != NULL) (void) GlobalFree(hPages); if (hBack != NULL) (void) GlobalFree(hBack); hWidths = hPages = hBack = NULL; if (hColor != NULL) { /* (void) GlobalFree(hColor); */ FreeColor(); /* also free saved stacks */ } /* if (hMarks != NULL) (void) GlobalFree(hMarks); */ if (hTPIC != NULL) (void) GlobalFree(hTPIC); if (hEncoding != NULL) (void) GlobalFree(hEncoding); /* 94/Dec/25 */ (void) FreeATMTables(); if (hATMShow != NULL) (void) GlobalFree(hATMShow); /* 94/Dec/31 */ hColor = hTPIC = hEncoding = hATMShow = NULL; if (szReencodingVector != NULL) free(szReencodingVector); /* 95/Jan/5 */ if (szEncodingVector != NULL) free (szEncodingVector); /* 98/Jul/10 */ FreeFontNames(); /* 95/July/7 in winpslog.c */ if (pd.hDevMode != NULL) GlobalFree(pd.hDevMode); /* PRINTDLG */ if (pd.hDevNames != NULL) GlobalFree(pd.hDevNames); /* PRINTDLG */ if (szPrintFile != NULL) free(szPrintFile); /* 95/Dec/25 */ if (szSource != NULL) free(szSource); /* 98/Dec/12 */ if (szEditorDDE != NULL) free(szEditorDDE); if (szTeXEdit != NULL) free(szTeXEdit); if (szCustom != NULL) free(szCustom); if (szCustomPageSize != NULL) free(szCustomPageSize); if (szBasePath != NULL) free(szBasePath); if (szEPSPath != NULL) free(szEPSPath); if (szVecPath != NULL) free(szVecPath); if (szPrePath != NULL) free(szPrePath); if (szTeXFonts != NULL) free(szTeXFonts); if (szTeXDVI != NULL) free(szTeXDVI); if (szRegistry != NULL) free(szRegistry); if (szWinDir != NULL) free(szWinDir); // winerror("Freeing szWinDir"); // szWinDir = NULL; if (szExeWindo != NULL) free(szExeWindo); if (logtext != NULL) free(logtext); FreeCommandStrings(); } #ifdef IGNORED HWND hPreviousWindow=NULL; BOOL CALLBACK _export EnumWindowsProc(HWND hwnd, LPARAM lParam) { int m; int n = strlen(TitleText); #ifdef DEBUGMAIN if (bDebug > 1) { sprintf(debugstr, "HWND %0lX LPARAM %0lX\n", hwnd, lParam); OutputDebugString(debugstr); } #endif /* Checking GetWindowTextLength > 0 first avoids exception in Windows NT */ if ((m = GetWindowTextLength(hwnd)) > 0) { /* 1996/Aug/4 */ /* if (bDebug > 1) { sprintf(debugstr, "HWND %0lX LPARAM %0lX m %d\n", hwnd, lParam, m); OutputDebugString(debugstr); } */ if (GetWindowText(hwnd, str, sizeof(str)) > 0) { /* if (bDebug > 1) { strcat(debugstr, "\n"); OutputDebugString(debugstr); } */ if (strncmp(str, TitleText, n) == 0) { hPreviousWindow = hwnd; return FALSE; /* to stop enumerating */ } } } return TRUE; /* to continue enumerating */ } /* lparam unreferenced */ #endif #ifdef IGNORED HWND FindPreviousWindow (void) { hPreviousWindow=NULL; #ifdef DEBUGINIT if (bDebug > 1) OutputDebugString("Enter FindPrevious\n"); #endif /* (void) EnumWindows((WNDENUMPROC) EnumWindowsProc, (LPARAM) NULL); */ if (EnumWindows((WNDENUMPROC) EnumWindowsProc, (LPARAM) NULL) == 0) return NULL; /* returns non-zero if successful */ #ifdef DEBUGINIT if (bDebug > 1) OutputDebugString("Exit FindPrevious\n"); #endif return hPreviousWindow; } #endif #ifdef IGNORED void checklong (void); /* for test code */ #endif /* get path to executable file */ /* moved out 1996/July/16 */ void setupexepath (HINSTANCE hInst) { HMODULE hModule; HFILE hFile; char *s; hModule = GetModuleHandle("dviwindo.exe"); *str = '\0'; /* 95/Dec/1 */ /* or can we just use hInst instead of hModule ? */ if (hModule == NULL) { /* winerror("Cannot get Module Handle"); */ if (bDebug > 1) OutputDebugString("Cannot get Module Handle"); hModule = hInst; /* back up in case renamed --- 96/June/5 */ } if (GetModuleFileName(hModule, str, sizeof(str)) > 0) { /* strip off executable name and leave path ending in \ */ if ((s = strrchr(str, '\\')) != NULL) s++; else if ((s = strrchr(str, '/')) != NULL) s++; else if ((s = strrchr(str, ':')) != NULL) s++; else s = str; *s = '\0'; /* exewindo = _strdup(str); */ /* 94/Aug/12 save some space */ szExeWindo = zstrdup(str); if (bDebug > 1) OutputDebugString(szExeWindo); /* We assume we are not going back to the old days of no long names */ #ifdef LONGNAMES /* Now see whether dviwindo.ini in same directory as dviwindo.exe */ strcat(str, "dviwindo.ini"); hFile = _lopen(str, READ | OfExistCode); /* 96/July/16 */ if (hFile != HFILE_ERROR) { achFile = zstrdup(str); _lclose (hFile); } #endif } else { winerror("Cannot get Module File Name"); szExeWindo = zstrdup(""); /* nonsense, should never happen */ } /* If dviwindo.ini not in same directory as dviwindo.exe, use no path */ /* if (*achFile == '\0') */ if (achFile == NULL) achFile = zstrdup("dviwindo.ini"); /* default ini file */ if (bDebug > 1) OutputDebugString(achFile); } /* Set up forward search DDE call to existing instance of DVIWindo 98/Dec/15 */ /* See also CallEditor in winanal.c */ int CallOtherInstance (char *ssrc, int nSourceLine, char *sdvi) { HSZ hszClientAppName=NULL, hszClientTopic=NULL; /* Service and Topic */ HCONV hConv; DWORD idClientInst, dwResult, dwTimeout; HDDEDATA hddret; int errcode; int flag = 0; /* normal return value */ /* repackage arguments and use DDE to send to self 98/Dec/15 */ /* DDEOpen("dviwindo.exe", "DVIWindo", "SRCSpecial"); */ /* DDEExe('[Open("%P\%N.dvi");Source("%n%t");Line(%l)]'); */ /* DDEClose; */ /* SetFocus("DVIWindo"); */ idClientInst = 0; errcode = DdeInitialize(&idClientInst, NULL, /* pfnCallback */ APPCLASS_STANDARD | APPCMD_CLIENTONLY | CBF_FAIL_ALLSVRXACTIONS | CBF_SKIP_ALLNOTIFICATIONS, /* afCmd filters */ 0L); /* ulRes must be zero */ if (errcode != DMLERR_NO_ERROR || idClientInst == 0) { /* failed ? */ #ifdef DEBUGDDE /* DMLERR_DLL_USAGE, DMLERR_INVALIDPARAMETER, DMLERR_SYS_ERROR */ if (bDebug > 1) { sprintf(debugstr, "DdeInitialize failed %04X", errcode); OutputDebugString(debugstr); } #endif return -1; /* safe to just quit here - noting to release */ } hszClientAppName = DdeCreateStringHandle(idClientInst, szApplication, CP_WINNEUTRAL); hszClientTopic = DdeCreateStringHandle(idClientInst, szTopic, CP_WINNEUTRAL); if (hszClientAppName == NULL || hszClientTopic == NULL) { #ifdef DEBUGDDE DdeFailureReport(idClientInst, "DdeCreateStringHandle"); #endif flag = -1; /* return -1; */ } else { /* now lets try and connect */ hConv = DdeConnect(idClientInst, hszClientAppName, hszClientTopic, NULL); if (hConv == NULL) { #ifdef DEBUGDDE DdeFailureReport(idClientInst, "DdeConnect"); #endif /* sprintf(debugstr, "Failed to connect to %s (%s)", szApplication, szTopic); */ /* winerror(debugstr); */ flag = -1; /* failed */ /* return -1; */ /* should not happen */ } else if (hConv != NULL) { if (bSearchCall) /* DDEExe('[Open("%P\%N.dvi");Source("%n%t");Line(%l)]'); */ sprintf(str, "[Open(\"%s\");Source(\"%s\");Line(%d)]", sdvi, ssrc, nSourceLine); else if (bPageCall) sprintf(str