| 1 | /***
|
|---|
| 2 | Main source of the Gotcha! screencapture program.
|
|---|
| 3 | Copyright (C) 1998-2002 Thorsten Thielen <thth@c2226.de>
|
|---|
| 4 |
|
|---|
| 5 | This program is free software; you can redistribute it and/or modify
|
|---|
| 6 | it under the terms of the GNU General Public License as published by
|
|---|
| 7 | the Free Software Foundation; either version 2 of the License, or
|
|---|
| 8 | (at your option) any later version.
|
|---|
| 9 |
|
|---|
| 10 | This program is distributed in the hope that it will be useful,
|
|---|
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 13 | GNU General Public License for more details.
|
|---|
| 14 |
|
|---|
| 15 | You should have received a copy of the GNU General Public License
|
|---|
| 16 | along with this program; if not, write to the Free Software
|
|---|
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 18 | ***/
|
|---|
| 19 |
|
|---|
| 20 | #define INCL_WINHOOKS
|
|---|
| 21 |
|
|---|
| 22 | #include "gotcha.h"
|
|---|
| 23 | #include "dll/gotchdll.h"
|
|---|
| 24 | #include "settings.h"
|
|---|
| 25 | #include "string.h"
|
|---|
| 26 |
|
|---|
| 27 | #include "io.h"
|
|---|
| 28 | #define INCL_EXCEPTQ_CLASS
|
|---|
| 29 | #define INCL_LOADEXCEPTQ
|
|---|
| 30 | #include "exceptq.h"
|
|---|
| 31 |
|
|---|
| 32 | HAB hab;
|
|---|
| 33 | HWND hwndFrame, hwndSnapshot;
|
|---|
| 34 | PFNWP OldFrameWP, wpOldButton;
|
|---|
| 35 | PSETTINGS pset;
|
|---|
| 36 | BOOL g_fIdle = FALSE, g_fSetPathName = FALSE;
|
|---|
| 37 | HWND g_hwndMenuSSW;
|
|---|
| 38 | HMODULE g_hmod = NULLHANDLE;
|
|---|
| 39 | Helper *g_phelp = NULL;
|
|---|
| 40 |
|
|---|
| 41 | #include "bitmap.cpp"
|
|---|
| 42 | #include "mainwin.cpp"
|
|---|
| 43 | #include "snapshot.cpp"
|
|---|
| 44 | #include "savebmp.cpp"
|
|---|
| 45 |
|
|---|
| 46 | // ** CheckCmdlineArgs **************************************************** /*FOLD00*/
|
|---|
| 47 |
|
|---|
| 48 | BOOL CheckCmdlineArgs (int argc, char *argv[])
|
|---|
| 49 | {
|
|---|
| 50 | BOOL fAuto = FALSE;
|
|---|
| 51 |
|
|---|
| 52 | for (USHORT i = 1; i < argc; i++)
|
|---|
| 53 | {
|
|---|
| 54 | // batch mode
|
|---|
| 55 | if ((stricmp (argv[i], "-a") == 0))
|
|---|
| 56 | {
|
|---|
| 57 | if (pset->QuerySaveStyle () != FSS_FORCEFILE)
|
|---|
| 58 | pset->SetFileSaveStyle (FSS_NUMFILES);
|
|---|
| 59 | fAuto = TRUE;
|
|---|
| 60 |
|
|---|
| 61 | if (i < argc-1)
|
|---|
| 62 | if (argv[i+1][0] != '-')
|
|---|
| 63 | {
|
|---|
| 64 | i++;
|
|---|
| 65 | pset->SetFileSaveStyle (FSS_NUMFILES);
|
|---|
| 66 | pset->SetNumSaveDir (argv[i]);
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 | // force saving to the given file name
|
|---|
| 70 | else if ((stricmp (argv[i], "-f") == 0) && (i < argc-1))
|
|---|
| 71 | {
|
|---|
| 72 | if (argv[i+1][0] != '-')
|
|---|
| 73 | {
|
|---|
| 74 | i++;
|
|---|
| 75 | pset->SetFileSaveStyle (FSS_FORCEFILE);
|
|---|
| 76 | pset->SetForceSaveFile (argv[i]);
|
|---|
| 77 | g_fSetPathName = TRUE;
|
|---|
| 78 | }
|
|---|
| 79 | }
|
|---|
| 80 | // set to idle priority
|
|---|
| 81 | else if (stricmp (argv[i], "-i") == 0)
|
|---|
| 82 | {
|
|---|
| 83 | g_fIdle = TRUE;
|
|---|
| 84 | pset->SetFlag (SEI_IDLEPRIORITY, TRUE);
|
|---|
| 85 | }
|
|---|
| 86 | }
|
|---|
| 87 |
|
|---|
| 88 | return fAuto;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | // ** main **************************************************************** /*FOLD00*/
|
|---|
| 92 |
|
|---|
| 93 | int main (int argc, PSZ argv[])
|
|---|
| 94 | {
|
|---|
| 95 | ScopedExceptqLoader sel;
|
|---|
| 96 | #ifdef _DOLOGDEBUG_
|
|---|
| 97 | LogDebug( "Gotcha! start" );
|
|---|
| 98 | #endif
|
|---|
| 99 | #ifdef _DOLOGMEM_
|
|---|
| 100 | LogMem("main", TRUE);
|
|---|
| 101 | #endif
|
|---|
| 102 |
|
|---|
| 103 | // init system and msg queue
|
|---|
| 104 | hab = WinInitialize (0);
|
|---|
| 105 | HMQ hmq = WinCreateMsgQueue (hab, 0);
|
|---|
| 106 |
|
|---|
| 107 | //DisplayError("DEBUG", "%d", Version());
|
|---|
| 108 | #ifdef _QUIET_
|
|---|
| 109 | if ((Version() < 2))
|
|---|
| 110 | {
|
|---|
| 111 | DisplayError("GOTCHDLL.DLL TOO OLD",
|
|---|
| 112 | "The file gotchdll.dll is to old for this version of "
|
|---|
| 113 | "Gotcha! Quiet As you should have received a sufficiently "
|
|---|
| 114 | "new version with the program, check if an older "
|
|---|
| 115 | "version of gotchdll.dll is still residing somewhere "
|
|---|
| 116 | "in your LIBPATH. And did you actually copy the new "
|
|---|
| 117 | "gotchdll.dll to some directory in your LIBPATH?");
|
|---|
| 118 | exit (0);
|
|---|
| 119 | }
|
|---|
| 120 | int rc;
|
|---|
| 121 | HMTX hmtx = NULLHANDLE;
|
|---|
| 122 | // running multiple instances orphans all but the first closed hook unloaded
|
|---|
| 123 | rc = DosOpenMutexSem("\\SEM32\\GOTCHA", &hmtx);
|
|---|
| 124 | if (!rc) {
|
|---|
| 125 | DisplayError("GOTCHA QUIET ALREADY RUNNING",
|
|---|
| 126 | "Another instance of Gotcha Quiet is running."
|
|---|
| 127 | " You can open Gotcha Quiet's settings using"
|
|---|
| 128 | " the Alt+Print Screen key combination");
|
|---|
| 129 | exit (0);
|
|---|
| 130 | }
|
|---|
| 131 | rc = DosCreateMutexSem("\\SEM32\\GOTCHA", &hmtx, 0, FALSE);
|
|---|
| 132 | if (rc) {
|
|---|
| 133 | DisplayError("Semaphore creation failed",
|
|---|
| 134 | "Try restarting Gotcha Quiet");
|
|---|
| 135 | exit (0);
|
|---|
| 136 | }
|
|---|
| 137 | #endif
|
|---|
| 138 |
|
|---|
| 139 | // register our window classes
|
|---|
| 140 | WinRegisterClass (hab, "thth.wc.gotcha.main", WindowProcedure, 0L,
|
|---|
| 141 | sizeof (ULONG)*2L);
|
|---|
| 142 | WinRegisterClass (hab, "thth.wc.gotcha.snapshot", wpSnapshot,
|
|---|
| 143 | CS_SIZEREDRAW, sizeof (ULONG)*2L);
|
|---|
| 144 |
|
|---|
| 145 | // load the settings
|
|---|
| 146 | pset = new SETTINGS;
|
|---|
| 147 |
|
|---|
| 148 | pset->idleSetInIni = pset->QueryFlag(SEI_IDLEPRIORITY);
|
|---|
| 149 | pset->saveStyle = pset->QuerySaveStyle ();
|
|---|
| 150 | pset->pNumSaveDir = pset->QueryNumSaveDir ();
|
|---|
| 151 | pset->pForceSaveFile = pset->QueryForceSaveFile();
|
|---|
| 152 | pset->bSerialCapture = pset->SerialCapture ();
|
|---|
| 153 |
|
|---|
| 154 | #ifdef _QUIET_
|
|---|
| 155 | bool fPrtScr = FALSE;
|
|---|
| 156 | ULONG ulDataSize = 0;
|
|---|
| 157 |
|
|---|
| 158 | rc = PrfQueryProfileSize( HINI_PROFILE, "PM_ControlPanel", "PrintScreen",
|
|---|
| 159 | &ulDataSize );
|
|---|
| 160 | rc = PrfQueryProfileData(HINI_USERPROFILE, "PM_ControlPanel", "PrintScreen",
|
|---|
| 161 | &fPrtScr, &ulDataSize);
|
|---|
| 162 | bool temp = FALSE;// always turn it off while running
|
|---|
| 163 | PrfWriteProfileData(HINI_USERPROFILE, "PM_ControlPanel",
|
|---|
| 164 | "PrintScreen", &temp, sizeof(bool));
|
|---|
| 165 | PrfQueryProfileSize(pset->QueryPrfHandle (), "PM",
|
|---|
| 166 | "PrintScreen", &ulDataSize );
|
|---|
| 167 | int rc1 = PrfQueryProfileData(pset->QueryPrfHandle (), "PM",
|
|---|
| 168 | "PrintScreen", &temp, &ulDataSize);
|
|---|
| 169 | bool temp2 = TRUE;
|
|---|
| 170 | PrfQueryProfileData(pset->QueryPrfHandle (), "PM",
|
|---|
| 171 | "PrintScreen", &temp2, &ulDataSize);
|
|---|
| 172 | if (!rc1 || (temp2 && (temp != fPrtScr))) { // no entry or user has changed PM setting
|
|---|
| 173 | if (!rc) // Print screen is on by default (no ini entry)
|
|---|
| 174 | fPrtScr = TRUE;
|
|---|
| 175 | PrfWriteProfileData(pset->QueryPrfHandle (), "PM",
|
|---|
| 176 | "PrintScreen", &fPrtScr, sizeof(bool));
|
|---|
| 177 | }
|
|---|
| 178 | temp = FALSE;
|
|---|
| 179 | PrfWriteProfileData(pset->QueryPrfHandle (), "PM",
|
|---|
| 180 | "Exited", &temp, sizeof(bool));
|
|---|
| 181 | #endif
|
|---|
| 182 | // check cmd line args and if "-a" found take screenshot and exit
|
|---|
| 183 | if (CheckCmdlineArgs (argc, argv))
|
|---|
| 184 | {
|
|---|
| 185 | CaptureWindow (HWND_DESKTOP, HWND_DESKTOP, NULL, TRUE);
|
|---|
| 186 | pset->SetFileSaveStyle(pset->saveStyle);
|
|---|
| 187 | pset->SetNumSaveDir (pset->pNumSaveDir);
|
|---|
| 188 | delete pset;
|
|---|
| 189 | WinDestroyMsgQueue (hmq);
|
|---|
| 190 | WinTerminate (hab);
|
|---|
| 191 | exit (0);
|
|---|
| 192 | }
|
|---|
| 193 |
|
|---|
| 194 | SetIdlePriority(pset->QueryFlag(SEI_IDLEPRIORITY));
|
|---|
| 195 |
|
|---|
| 196 | // create the windows
|
|---|
| 197 | hwndFrame = CreateMainWindow ();
|
|---|
| 198 | hwndSnapshot = CreateSnapshotWindow ();
|
|---|
| 199 |
|
|---|
| 200 | SWP swp;
|
|---|
| 201 | USHORT us[7];
|
|---|
| 202 |
|
|---|
| 203 | // position main window
|
|---|
| 204 | pset->QueryWindowData (&swp, us, FALSE);
|
|---|
| 205 | WinSetWindowPos (hwndFrame, HWND_DESKTOP, swp.x,swp.y, 0,0,
|
|---|
| 206 | SWP_SHOW | SWP_MOVE);
|
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 | #ifdef _QUIET_
|
|---|
| 210 | InitDLL (hab, hwndFrame);
|
|---|
| 211 | StartInputHook ();
|
|---|
| 212 | #endif
|
|---|
| 213 |
|
|---|
| 214 | // position snapshot window
|
|---|
| 215 | pset->QueryWindowData (&swp, us);
|
|---|
| 216 |
|
|---|
| 217 | // size, activate & show window
|
|---|
| 218 | WinSetWindowPos (hwndSnapshot, HWND_DESKTOP, swp.x,swp.y, swp.cx,swp.cy,
|
|---|
| 219 | SWP_SHOW | SWP_SIZE | SWP_MOVE);
|
|---|
| 220 | if (! pset->SnapshotWindow ())
|
|---|
| 221 | WinShowWindow (hwndSnapshot, FALSE);
|
|---|
| 222 | else
|
|---|
| 223 | WinShowWindow (hwndSnapshot, TRUE);
|
|---|
| 224 |
|
|---|
| 225 | WinSetWindowPos (hwndFrame, NULLHANDLE, 0,0, 0,0, SWP_SHOW);
|
|---|
| 226 | WinSetWindowPos (WinWindowFromID (hwndFrame, FID_CLIENT), NULLHANDLE,
|
|---|
| 227 | 0,0, 0,0, SWP_SHOW);
|
|---|
| 228 |
|
|---|
| 229 | g_phelp = new Helper(hwndFrame);
|
|---|
| 230 |
|
|---|
| 231 |
|
|---|
| 232 | // do the main msg loop
|
|---|
| 233 | QMSG qmsg;
|
|---|
| 234 | while (WinGetMsg (hab, &qmsg, 0L, 0, 0))
|
|---|
| 235 | WinDispatchMsg (hab, &qmsg);
|
|---|
| 236 |
|
|---|
| 237 |
|
|---|
| 238 | // Set priorty to unless user set regular since running -q sets it to idle in the ini
|
|---|
| 239 | if (g_fIdle) {
|
|---|
| 240 | pset->SetFlag (SEI_IDLEPRIORITY, pset->idleSetInIni);
|
|---|
| 241 | }
|
|---|
| 242 | // Don't change the ini stored paths if the paths were set from the command line
|
|---|
| 243 | if (g_fSetPathName) {
|
|---|
| 244 | pset->SetFileSaveStyle(pset->saveStyle);
|
|---|
| 245 | pset->SetForceSaveFile (pset->pForceSaveFile);
|
|---|
| 246 | pset->SetNumSaveDir (pset->pNumSaveDir);
|
|---|
| 247 | }
|
|---|
| 248 | // save size, etc. of snapshot window
|
|---|
| 249 | WinQueryWindowPos (hwndSnapshot, &swp);
|
|---|
| 250 | pset->SetWindowData (&swp);
|
|---|
| 251 |
|
|---|
| 252 | // save size, etc. of main window
|
|---|
| 253 | WinQueryWindowPos (hwndFrame, &swp);
|
|---|
| 254 | pset->SetWindowData (&swp, FALSE);
|
|---|
| 255 |
|
|---|
| 256 | // goodbye windows!
|
|---|
| 257 | WinDestroyWindow (hwndSnapshot);
|
|---|
| 258 | WinDestroyWindow (hwndFrame);
|
|---|
| 259 |
|
|---|
| 260 | #ifdef _QUIET_
|
|---|
| 261 | PrfQueryProfileSize(pset->QueryPrfHandle (), "PM",
|
|---|
| 262 | "PrintScreen", &ulDataSize );
|
|---|
| 263 | PrfQueryProfileData(pset->QueryPrfHandle (), "PM",
|
|---|
| 264 | "PrintScreen", &fPrtScr, &ulDataSize);
|
|---|
| 265 | PrfWriteProfileData(HINI_USERPROFILE, "PM_ControlPanel", "PrintScreen",
|
|---|
| 266 | &fPrtScr, sizeof(bool));
|
|---|
| 267 | temp = TRUE;
|
|---|
| 268 | PrfWriteProfileData(pset->QueryPrfHandle (), "PM",
|
|---|
| 269 | "Exited", &temp, sizeof(bool));
|
|---|
| 270 |
|
|---|
| 271 | StopInputHook ();
|
|---|
| 272 | DosCloseMutexSem(hmtx);
|
|---|
| 273 | #endif
|
|---|
| 274 |
|
|---|
| 275 | delete g_phelp;
|
|---|
| 276 | delete pset;
|
|---|
| 277 |
|
|---|
| 278 | WinDestroyMsgQueue (hmq);
|
|---|
| 279 | WinTerminate (hab);
|
|---|
| 280 |
|
|---|
| 281 | #ifdef _DOLOGMEM_
|
|---|
| 282 | LogMem("main", FALSE);
|
|---|
| 283 | #endif
|
|---|
| 284 | #ifdef _DOLOGDEBUG_
|
|---|
| 285 | LogDebug( "Gotcha! end" );
|
|---|
| 286 | #endif
|
|---|
| 287 | }
|
|---|
| 288 |
|
|---|
| 289 | // ** DisplayError ******************************************************** /*FOLD00*/
|
|---|
| 290 |
|
|---|
| 291 | VOID DisplayError (PSZ pszTitle, PSZ psz, ...)
|
|---|
| 292 | {
|
|---|
| 293 | CHAR dstring[401];
|
|---|
| 294 | va_list valst;
|
|---|
| 295 |
|
|---|
| 296 | va_start (valst, psz);
|
|---|
| 297 | vsnprintf (dstring, 401, psz, valst);
|
|---|
| 298 | va_end (valst);
|
|---|
| 299 |
|
|---|
| 300 | WinMessageBox (HWND_DESKTOP, WinQueryActiveWindow (HWND_DESKTOP), dstring,
|
|---|
| 301 | pszTitle, 0, MB_OK | MB_ERROR | MB_APPLMODAL | MB_MOVEABLE);
|
|---|
| 302 | }
|
|---|
| 303 |
|
|---|
| 304 | // saymsg2 was adapted from code in FM/2
|
|---|
| 305 | APIRET saymsg2(int DefaultButton, HWND hwnd, PCSZ pszTitle, PCSZ pszFmt, ...)
|
|---|
| 306 | {
|
|---|
| 307 | ULONG i;
|
|---|
| 308 | APIRET rc;
|
|---|
| 309 | CHAR szMsg[4096];
|
|---|
| 310 | va_list va;
|
|---|
| 311 | MB2INFO *pmbInfo;
|
|---|
| 312 | MB2D mb2dBut[3];
|
|---|
| 313 | ULONG ulInfoSize = (sizeof(MB2INFO) + (sizeof(MB2D) * 2));
|
|---|
| 314 |
|
|---|
| 315 | va_start(va, pszFmt);
|
|---|
| 316 | szMsg[sizeof(szMsg) - 1] = 0;
|
|---|
| 317 | vsprintf(szMsg, pszFmt, va);
|
|---|
| 318 | va_end(va);
|
|---|
| 319 |
|
|---|
| 320 | if (szMsg[sizeof(szMsg) - 1]) {
|
|---|
| 321 | fprintf(stderr, "Buffer overflow in saymsg2 - need %u bytes\n", strlen(szMsg) + 1);
|
|---|
| 322 | fflush(stderr);
|
|---|
| 323 | }
|
|---|
| 324 |
|
|---|
| 325 | memset(mb2dBut, 0, sizeof(MB2D) * 3);
|
|---|
| 326 | strcpy(mb2dBut[0].achText,"Ok");
|
|---|
| 327 | strcpy(mb2dBut[1].achText,"Cancel");
|
|---|
| 328 | strcpy(mb2dBut[2].achText,"Settings");
|
|---|
| 329 | mb2dBut[0].idButton = 1;
|
|---|
| 330 | mb2dBut[1].idButton = 2;
|
|---|
| 331 | mb2dBut[2].idButton = 3;
|
|---|
| 332 | if (DefaultButton)
|
|---|
| 333 | mb2dBut[DefaultButton - 1].flStyle = BS_DEFAULT;
|
|---|
| 334 | pmbInfo = (MB2INFO *) malloc(ulInfoSize);
|
|---|
| 335 | memset(pmbInfo, 0, ulInfoSize);
|
|---|
| 336 | if (pmbInfo) {
|
|---|
| 337 | pmbInfo->cb = ulInfoSize;
|
|---|
| 338 | pmbInfo->hIcon = 0;
|
|---|
| 339 | pmbInfo->cButtons = 3;
|
|---|
| 340 | pmbInfo->flStyle = MB_MOVEABLE | MB_ICONQUESTION ;
|
|---|
| 341 | pmbInfo->hwndNotify = NULLHANDLE;
|
|---|
| 342 | for (i = 0; i < 3; i++) {
|
|---|
| 343 | memcpy( pmbInfo->mb2d+i , mb2dBut+i , sizeof(MB2D));
|
|---|
| 344 | }
|
|---|
| 345 | rc = WinMessageBox2(HWND_DESKTOP, hwnd,
|
|---|
| 346 | szMsg, pszTitle, SM2_DIALOG,
|
|---|
| 347 | pmbInfo);
|
|---|
| 348 | WinSetFocus(HWND_DESKTOP, SM2_DIALOG);
|
|---|
| 349 | free(pmbInfo);
|
|---|
| 350 | return rc;
|
|---|
| 351 | }
|
|---|
| 352 | return MBID_ERROR;
|
|---|
| 353 | }
|
|---|
| 354 | // ** AddSysMenuItem ****************************************************** /*FOLD00*/
|
|---|
| 355 |
|
|---|
| 356 | VOID AddSysMenuItem (HWND hwndFrame, MENUITEM *Item, PSZ Text)
|
|---|
| 357 | {
|
|---|
| 358 | HWND hwndSysMenu = WinWindowFromID (hwndFrame, FID_SYSMENU);
|
|---|
| 359 | USHORT idSysMenu = SHORT1FROMMR (WinSendMsg (hwndSysMenu,
|
|---|
| 360 | MM_ITEMIDFROMPOSITION, NULL,
|
|---|
| 361 | NULL ));
|
|---|
| 362 | MENUITEM miSysMenu;
|
|---|
| 363 | WinSendMsg (hwndSysMenu, MM_QUERYITEM,
|
|---|
| 364 | MPFROM2SHORT (idSysMenu,FALSE), MPFROMP(&miSysMenu));
|
|---|
| 365 |
|
|---|
| 366 | HWND hwndSysSubMenu = miSysMenu.hwndSubMenu;
|
|---|
| 367 |
|
|---|
| 368 | WinSendMsg (hwndSysSubMenu, MM_INSERTITEM, MPFROMP(Item), MPFROMP(Text));
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | // ** DoCountdown ********************************************************* /*fold00*/
|
|---|
| 372 |
|
|---|
| 373 | VOID DoCountdown (ULONG ul)
|
|---|
| 374 | {
|
|---|
| 375 | if (ul > 10)
|
|---|
| 376 | DosBeep (4000L-3000L, 20);
|
|---|
| 377 | else
|
|---|
| 378 | DosBeep (4000L-ul*300L, 20);
|
|---|
| 379 | }
|
|---|
| 380 |
|
|---|
| 381 | // ** SetIdlePriority **************************************************** /*FOLD00*/
|
|---|
| 382 |
|
|---|
| 383 | VOID SetIdlePriority (BOOL f)
|
|---|
| 384 | {
|
|---|
| 385 | #if 0 //#ifndef _QUEIT_
|
|---|
| 386 | if (f)
|
|---|
| 387 | DosSetPriority(PRTYS_PROCESS, PRTYC_IDLETIME, 0, 0);
|
|---|
| 388 | else
|
|---|
| 389 | DosSetPriority(PRTYS_PROCESS, PRTYC_REGULAR, 0, 0);
|
|---|
| 390 | #else
|
|---|
| 391 | DosSetPriority(PRTYS_PROCESS, PRTYC_FOREGROUNDSERVER, 0, 0);
|
|---|
| 392 | #endif
|
|---|
| 393 | }
|
|---|
| 394 |
|
|---|
| 395 | // ***********************************************************************
|
|---|
| 396 |
|
|---|
| 397 | #ifdef _DOLOGMEM_
|
|---|
| 398 | VOID LogMem (PSZ psz, BOOL f)
|
|---|
| 399 | {
|
|---|
| 400 | FILE *pf = fopen("gotcha.mem","ab");
|
|---|
| 401 | static ULONG TotalPhysicalMemory, ul = 0;
|
|---|
| 402 | ULONG i;
|
|---|
| 403 | if (!f)
|
|---|
| 404 | ul--;
|
|---|
| 405 | DosQuerySysInfo(QSV_TOTAVAILMEM, QSV_TOTAVAILMEM, &TotalPhysicalMemory,
|
|---|
| 406 | sizeof(TotalPhysicalMemory));
|
|---|
| 407 | for (i = 0; i < ul; i++)
|
|---|
| 408 | fputs(" ", pf);
|
|---|
| 409 | fprintf(pf,"%10ld (%s)\n", TotalPhysicalMemory, psz);
|
|---|
| 410 | if (f)
|
|---|
| 411 | ul++;
|
|---|
| 412 | fclose(pf);
|
|---|
| 413 | }
|
|---|
| 414 | #endif
|
|---|
| 415 |
|
|---|
| 416 | #ifdef _DOLOGDEBUG_
|
|---|
| 417 | VOID LogDebug( PSZ psz, ... )
|
|---|
| 418 | {
|
|---|
| 419 | CHAR dstring[401];
|
|---|
| 420 | va_list valst;
|
|---|
| 421 |
|
|---|
| 422 | va_start (valst, psz);
|
|---|
| 423 | vsnprintf (dstring, 401, psz, valst);
|
|---|
| 424 | va_end (valst);
|
|---|
| 425 |
|
|---|
| 426 | FILE *pf = fopen( "gotcha.log", "ab" );
|
|---|
| 427 | fprintf( pf, "%s\n", dstring );
|
|---|
| 428 | fclose( pf );
|
|---|
| 429 | }
|
|---|
| 430 | #endif
|
|---|
| 431 |
|
|---|
| 432 | // ***********************************************************************
|
|---|