|
|
1.1 ! root 1: #include "porttool.h" ! 2: #include "port.h" ! 3: ! 4: #define DLGOFFSET 70 ! 5: RESULT rIssue; ! 6: ! 7: HANDLE hBkFileHeap; ! 8: ! 9: ! 10: // function prototypes for helper functions ! 11: void WINAPI GrowDialog (HWND, BOOL); ! 12: BOOL WINAPI GetHelpFileName (char *); ! 13: BOOL WINAPI BuildFileList (char *, LPBKFILELIST *); ! 14: BOOL WINAPI AddFile (char *, char *, BKFILELIST *); ! 15: BOOL WINAPI RemoveFile (char *, LPBKFILELIST *); ! 16: BOOL WINAPI FreeFileList (BKFILELIST *); ! 17: ! 18: // port options dialog ! 19: BOOL WINAPI OptionsDlgProc ( ! 20: HWND hDlg, ! 21: UINT uMsg, ! 22: UINT uParam, ! 23: LONG lParam) ! 24: { ! 25: BOOL bRet = TRUE; ! 26: static DWORD *dwPTFlags; ! 27: static HFONT hStrikeoutFont; ! 28: static HFONT hSystemFont; ! 29: LOGFONT lf; ! 30: ! 31: switch (uMsg) ! 32: { ! 33: case WM_INITDIALOG: ! 34: // create strikeout font for ignored tokens ! 35: hSystemFont = GetStockObject (SYSTEM_FONT); ! 36: GetObject (hSystemFont, sizeof (LOGFONT), &lf); ! 37: lf.lfStrikeOut = TRUE; ! 38: hStrikeoutFont = CreateFontIndirect (&lf); ! 39: ! 40: // initialize token control with stock system font ! 41: SendMessage (GetDlgItem (hDlg, IDC_CURTOKEN), ! 42: WM_SETFONT, ! 43: (UINT)hSystemFont, ! 44: FALSE); ! 45: ! 46: // save dwPTFlags from lParam ! 47: dwPTFlags = (DWORD *)lParam; ! 48: ! 49: // initialize current token if any ! 50: if (*(WORD *)rIssue.lpszToken != MAXTOKENLEN) ! 51: SetDlgItemText (hDlg, IDC_CURTOKEN, rIssue.lpszToken); ! 52: else ! 53: EnableWindow (GetDlgItem (hDlg, IDC_IGNORETOKEN), FALSE); ! 54: ! 55: // initialize search flag check boxes ! 56: CheckDlgButton (hDlg, IDC_NOAPIS, (*dwPTFlags & PT_NOAPIS)); ! 57: CheckDlgButton (hDlg, IDC_NOMESSAGES, (*dwPTFlags & PT_NOMESSAGES)); ! 58: CheckDlgButton (hDlg, IDC_NOSTRUCTURES, (*dwPTFlags & PT_NOSTRUCTURES)); ! 59: CheckDlgButton (hDlg, IDC_NOMACROS, (*dwPTFlags & PT_NOMACROS)); ! 60: CheckDlgButton (hDlg, IDC_NOCONSTANTS, (*dwPTFlags & PT_NOCONSTANTS)); ! 61: CheckDlgButton (hDlg, IDC_NOTYPES, (*dwPTFlags & PT_NOTYPES)); ! 62: CheckDlgButton (hDlg, IDC_NOCUSTOM, (*dwPTFlags & PT_NOCUSTOM)); ! 63: CheckDlgButton (hDlg, IDC_IGNORECASE, (*dwPTFlags & PT_IGNORECASE)); ! 64: ! 65: // set focus to first check box, return FALSE ! 66: SetFocus (GetDlgItem (hDlg, IDC_NOAPIS)); ! 67: bRet = FALSE; ! 68: break; ! 69: ! 70: case WM_COMMAND: ! 71: switch (LOWORD (uParam)) ! 72: { ! 73: case IDOK: ! 74: // get check box states and return as FLAGS in UM_PORT message ! 75: *dwPTFlags = (*dwPTFlags & ~PT_IGNORECASE) ^ ! 76: (IsDlgButtonChecked (hDlg, IDC_IGNORECASE) ? PT_IGNORECASE : 0); ! 77: *dwPTFlags = (*dwPTFlags & ~PT_NOAPIS) ^ ! 78: (IsDlgButtonChecked (hDlg, IDC_NOAPIS) ? PT_NOAPIS : 0); ! 79: *dwPTFlags = (*dwPTFlags & ~PT_NOMESSAGES) ^ ! 80: (IsDlgButtonChecked (hDlg, IDC_NOMESSAGES) ? PT_NOMESSAGES : 0); ! 81: *dwPTFlags = (*dwPTFlags & ~PT_NOSTRUCTURES) ^ ! 82: (IsDlgButtonChecked (hDlg, IDC_NOSTRUCTURES) ? PT_NOSTRUCTURES : 0); ! 83: *dwPTFlags = (*dwPTFlags & ~PT_NOMACROS) ^ ! 84: (IsDlgButtonChecked (hDlg, IDC_NOMACROS) ? PT_NOMACROS : 0); ! 85: *dwPTFlags = (*dwPTFlags & ~PT_NOCONSTANTS) ^ ! 86: (IsDlgButtonChecked (hDlg, IDC_NOCONSTANTS) ? PT_NOCONSTANTS : 0); ! 87: *dwPTFlags = (*dwPTFlags & ~PT_NOTYPES) ^ ! 88: (IsDlgButtonChecked (hDlg, IDC_NOTYPES) ? PT_NOTYPES : 0); ! 89: *dwPTFlags = (*dwPTFlags & ~PT_NOCUSTOM) ^ ! 90: (IsDlgButtonChecked (hDlg, IDC_NOCUSTOM) ? PT_NOCUSTOM : 0); ! 91: ! 92: case IDCANCEL: ! 93: SendMessage (GetDlgItem (hDlg, IDC_CURTOKEN), WM_SETFONT, NULL, FALSE); ! 94: DeleteObject (hStrikeoutFont); ! 95: EndDialog (hDlg, LOWORD (uParam) == IDOK); ! 96: break; ! 97: ! 98: case IDC_IGNORETOKEN: ! 99: // toggle ignore bit ! 100: *dwPTFlags ^= PT_IGNORETOKEN; ! 101: ! 102: // have control draw in strikeout if ignored ! 103: if (*dwPTFlags & PT_IGNORETOKEN) ! 104: SendMessage (GetDlgItem (hDlg, IDC_CURTOKEN), ! 105: WM_SETFONT, ! 106: (UINT)hStrikeoutFont, ! 107: TRUE); ! 108: // else draw in system font ! 109: else ! 110: SendMessage (GetDlgItem (hDlg, IDC_CURTOKEN), ! 111: WM_SETFONT, ! 112: (UINT)hSystemFont, ! 113: TRUE); ! 114: break; ! 115: } ! 116: break; ! 117: ! 118: default: ! 119: bRet = FALSE; ! 120: break; ! 121: } ! 122: ! 123: // return (message was processed); ! 124: return bRet; ! 125: } ! 126: ! 127: ! 128: ! 129: // port options dialog ! 130: BOOL WINAPI PortDlgProc ( ! 131: HWND hDlg, ! 132: UINT uMsg, ! 133: UINT uParam, ! 134: LONG lParam) ! 135: { ! 136: BOOL bRet = TRUE; ! 137: static DWORD dwPTFlags; ! 138: static BOOL bSearching = TRUE; ! 139: static BOOL bHelpActive = FALSE, bIsHelpFile = FALSE; ! 140: static HBRUSH hBkBrush; ! 141: static HWND hWndEdit; ! 142: static HANDLE hEditData; ! 143: static int nIssues = 0; ! 144: static int iLineNo, iStartPos; ! 145: static HLOCAL hToken, hHelp, hIssue, hSuggest; ! 146: static HLOCAL hEditLine; ! 147: ! 148: ! 149: switch (uMsg) ! 150: { ! 151: case WM_INITDIALOG: ! 152: { ! 153: char lpszTitle[MAX_PATH]; ! 154: char lpszFilename[MAX_PATH]; ! 155: RECT rc; ! 156: ! 157: ! 158: // reposition self on bottom of screen ! 159: GetWindowRect (hDlg, &rc); ! 160: SetWindowPos (hDlg, ! 161: NULL, ! 162: rc.left, ! 163: GetSystemMetrics (SM_CYSCREEN) - ! 164: (rc.bottom - rc.top + DLGOFFSET), ! 165: rc.right-rc.left, ! 166: rc.bottom-rc.top, ! 167: SWP_NOZORDER | SWP_NOREDRAW | SWP_NOSIZE); ! 168: ! 169: // set help available flag ! 170: if (GetHelpFileName (lpszTitle)) ! 171: { ! 172: EnableWindow (GetDlgItem (hDlg, IDC_HELP), TRUE); ! 173: bIsHelpFile = TRUE; ! 174: } ! 175: ! 176: // allocate strings for Issue struct from local heap to reduce stack overhead ! 177: if (!(rIssue.lpszToken = LocalLock (hToken = LocalAlloc (LHND, MAXTOKENLEN))) || ! 178: !(rIssue.lpszHelpStr = LocalLock (hHelp = LocalAlloc (LHND, MAXHELPLEN))) || ! 179: !(rIssue.lpszIssue = LocalLock (hIssue = LocalAlloc (LHND, MAXISSUELEN))) || ! 180: !(rIssue.lpszSuggest = LocalLock (hSuggest = LocalAlloc (LHND, MAXSUGGESTLEN)))) ! 181: { ! 182: ErrorNotify (hDlg, IDS_MEMORYFAILED); ! 183: PostMessage (hDlg, WM_COMMAND, IDC_DONE, 0); ! 184: break; ! 185: } ! 186: ! 187: // initialize line and token offset position stuff ! 188: iLineNo = 0; ! 189: iStartPos = 0; ! 190: rIssue.nPosToken = 0; ! 191: ! 192: // initialize background brush for use in WM_CTLCOLOR message ! 193: hBkBrush = (HBRUSH)GetClassLong (hDlg, GCL_HBRBACKGROUND); ! 194: ! 195: // set initial search flags to default ! 196: dwPTFlags = 0; ! 197: ! 198: // initialize filename in caption ! 199: LoadString (GetModuleHandle (NULL), IDS_PORTFILE, lpszTitle, strlen (lpszTitle)); ! 200: GetFileFromPath (lpszFilePath, lpszFilename); ! 201: strcat (lpszTitle, lpszFilename); ! 202: SetWindowText (hDlg, lpszTitle); ! 203: ! 204: // IDC_SUGGESTION to SW_HIDE ! 205: ShowWindow (GetDlgItem (hDlg, IDC_SUGGESTION), SW_HIDE); ! 206: ShowWindow (GetDlgItem (hDlg, IDC_SUGGESTLABEL), SW_HIDE); ! 207: ! 208: // get edit window and data handle ! 209: hWndEdit = (HWND)GetWindowLong (GetParent (hDlg), WL_HWNDEDIT); ! 210: hEditData = (HANDLE)SendMessage (hWndEdit, EM_GETHANDLE, 0, 0); ! 211: ! 212: // allocate here, reallocate later when needed ! 213: hEditLine = LocalAlloc (LHND, 1); ! 214: ! 215: // post message to start ball rolling ! 216: PostMessage (hDlg, WM_COMMAND, (UINT)IDC_CONTINUE, 0); ! 217: ! 218: // don't worry about focus here since were going to drive the search anyway ! 219: bRet = TRUE; ! 220: } ! 221: break; ! 222: ! 223: case WM_COMMAND: ! 224: switch (LOWORD (uParam)) ! 225: { ! 226: case IDC_CONTINUE: ! 227: { ! 228: int iLastLine, nCharOffset, nLineLen; ! 229: MSG msg; ! 230: char lpszBuff[MAXTOKENLEN]; ! 231: char *lpszLine; ! 232: char *lpLine; ! 233: char *lpEditData; ! 234: ! 235: // disable continue button ! 236: EnableWindow (GetDlgItem (hDlg, IDC_CONTINUE), FALSE); ! 237: EnableWindow (GetDlgItem (hDlg, IDC_OPTIONS), FALSE); ! 238: EnableWindow (GetDlgItem (hDlg, IDCANCEL), TRUE); ! 239: ! 240: // set IDC_SEARCHFOUND to green searching ! 241: LoadString (GetModuleHandle (NULL), IDS_SEARCHING, ! 242: lpszBuff, ! 243: sizeof (lpszBuff)); ! 244: SetWindowText (GetDlgItem (hDlg, IDC_SEARCHFOUND), lpszBuff); ! 245: bSearching = TRUE; ! 246: ! 247: // set last line ! 248: iLastLine = (int)SendMessage (hWndEdit, EM_GETLINECOUNT, 0, 0); ! 249: ! 250: // find next port issue ! 251: while (TRUE) ! 252: { ! 253: if (iLineNo >= iLastLine) ! 254: { ! 255: // no more issues found, so clean up and go away ! 256: ErrorNotify (hDlg, IDS_NOMOREPORTISSUES); ! 257: ! 258: // nullify any selection in line edit control ! 259: SendMessage (GetDlgItem (hDlg, IDC_LINE), EM_SETSEL, 0, 0); ! 260: break; ! 261: } ! 262: ! 263: // increment line no ! 264: SetWindowText (GetDlgItem (hDlg, IDC_LINENO), ! 265: itoa (iLineNo, lpszBuff, 10)); ! 266: ! 267: // get length and number of edit line ! 268: nCharOffset = SendMessage (hWndEdit, EM_LINEINDEX, iLineNo, 0); ! 269: if ((nLineLen = SendMessage (hWndEdit, EM_LINELENGTH, nCharOffset, 0)) <= 2) ! 270: goto NEXT_LINE; ! 271: ! 272: // allocate enough memory for edit line ! 273: if (!(hEditLine = LocalReAlloc (hEditLine, ! 274: nLineLen+1, ! 275: LHND))) ! 276: { ! 277: // no more issues found, so clean up and go away ! 278: ErrorNotify (hDlg, IDS_MEMORYFAILED); ! 279: PostMessage (hDlg, WM_COMMAND, IDC_DONE, 0); ! 280: break; ! 281: } ! 282: ! 283: // get line from edit control, and null terminate ! 284: lpEditData = LocalLock (hEditData); ! 285: lpLine = lpszLine = LocalLock (hEditLine); ! 286: strncpy (lpszLine, lpEditData+nCharOffset, nLineLen); ! 287: lpszLine[nLineLen] = 0; ! 288: ! 289: // increment the token position for multiple errors in a line ! 290: lpLine += iStartPos; ! 291: LocalUnlock (hEditData); ! 292: ! 293: // initialize line and hilight token ! 294: SetWindowText (GetDlgItem (hDlg, IDC_LINE), lpszLine); ! 295: ! 296: // reinitialize rIssue strings lengths ! 297: *(WORD *)rIssue.lpszToken = MAXTOKENLEN; ! 298: *(WORD *)rIssue.lpszHelpStr = MAXHELPLEN; ! 299: *(WORD *)rIssue.lpszIssue = MAXISSUELEN; ! 300: *(WORD *)rIssue.lpszSuggest = MAXSUGGESTLEN; ! 301: ! 302: // search next line ! 303: if (CheckString (lpLine, dwPTFlags, &rIssue)) ! 304: { ! 305: // set SEARCHFOUND string to found ! 306: LoadString (GetModuleHandle (NULL), ! 307: IDS_FOUND, ! 308: lpszBuff, ! 309: sizeof (lpszBuff)); ! 310: strcat (lpszBuff, rIssue.lpszToken); ! 311: SetWindowText (GetDlgItem (hDlg, IDC_SEARCHFOUND), lpszBuff); ! 312: ! 313: // reenable options button ! 314: EnableWindow (GetDlgItem (hDlg, IDC_OPTIONS), TRUE); ! 315: ! 316: // set searching flag off ! 317: bSearching = FALSE; ! 318: ! 319: // increment issue cnt ! 320: SetWindowText (GetDlgItem (hDlg, IDC_ISSUECNT), ! 321: itoa (++nIssues, lpszBuff, 10)); ! 322: ! 323: // initialize Issue ! 324: SetWindowText (GetDlgItem (hDlg, IDC_ISSUE), rIssue.lpszIssue); ! 325: ! 326: // if help, enble button ! 327: EnableWindow (GetDlgItem (hDlg, IDC_HELP), ! 328: ((*(rIssue.lpszSuggest) != 0) && bIsHelpFile)); ! 329: ! 330: // if suggest, show suggestion ! 331: if (*(rIssue.lpszSuggest)) ! 332: { ! 333: SetWindowText (GetDlgItem (hDlg, IDC_SUGGESTION), ! 334: rIssue.lpszSuggest); ! 335: if (!IsWindowVisible (GetDlgItem (hDlg, IDC_SUGGESTION))) ! 336: GrowDialog (hDlg, TRUE); ! 337: } ! 338: ! 339: else if (IsWindowVisible (GetDlgItem (hDlg, IDC_SUGGESTION))) ! 340: GrowDialog (hDlg, FALSE); ! 341: ! 342: // scroll parent edit control and select offending text ! 343: SendMessage (hWndEdit, EM_LINESCROLL, 0, iLineNo - ! 344: SendMessage (hWndEdit, EM_GETFIRSTVISIBLELINE, 0, 0)); ! 345: SendMessage (hWndEdit, ! 346: EM_SETSEL, ! 347: iStartPos + nCharOffset + rIssue.nPosToken, ! 348: iStartPos + nCharOffset + rIssue.nPosToken + ! 349: strlen (rIssue.lpszToken)); ! 350: ! 351: // select text in line edit control ! 352: SendMessage (GetDlgItem (hDlg, IDC_LINE), ! 353: EM_SETSEL, ! 354: iStartPos + rIssue.nPosToken, ! 355: iStartPos + rIssue.nPosToken + ! 356: strlen (rIssue.lpszToken)); ! 357: ! 358: // reset nPosToken to check rest of line ! 359: iStartPos += (rIssue.nPosToken + strlen (rIssue.lpszToken)); ! 360: LocalUnlock (hEditLine); ! 361: break; ! 362: } ! 363: ! 364: // call peek message to let user cancel if they choose ! 365: if (PeekMessage (&msg, ! 366: GetDlgItem (hDlg, IDCANCEL), ! 367: WM_LBUTTONDOWN, ! 368: WM_LBUTTONDOWN, ! 369: PM_REMOVE)) ! 370: { ! 371: // reset appropriate buttons ! 372: EnableWindow (GetDlgItem (hDlg, IDCANCEL), FALSE); ! 373: EnableWindow (GetDlgItem (hDlg, IDC_HELP), FALSE); ! 374: EnableWindow (GetDlgItem (hDlg, IDC_OPTIONS), TRUE); ! 375: ! 376: // break to let message get delivered ! 377: break; ! 378: } ! 379: ! 380: // also let the user exit from searching ! 381: if (PeekMessage (&msg, ! 382: GetDlgItem (hDlg, IDC_DONE), ! 383: WM_LBUTTONDOWN, ! 384: WM_LBUTTONDOWN, ! 385: PM_REMOVE)) ! 386: { ! 387: PostMessage (hDlg, WM_COMMAND, IDC_DONE, 0); ! 388: break; ! 389: } ! 390: ! 391: // unlock local edit line ! 392: LocalUnlock (hEditLine); ! 393: ! 394: // reset token position ! 395: rIssue.nPosToken = 0; ! 396: iStartPos = 0; ! 397: NEXT_LINE: ! 398: // increment line and continue ! 399: iLineNo++; ! 400: } ! 401: ! 402: // enable continue button unless at end of file ! 403: if (iLineNo < iLastLine) ! 404: { ! 405: EnableWindow (GetDlgItem (hDlg, IDC_CONTINUE), TRUE); ! 406: SetFocus (GetDlgItem (hDlg, IDC_CONTINUE)); ! 407: } ! 408: else ! 409: { ! 410: EnableWindow (GetDlgItem (hDlg, IDC_CONTINUE), FALSE); ! 411: EnableWindow (GetDlgItem (hDlg, IDCANCEL), FALSE); ! 412: SetFocus (GetDlgItem (hDlg, IDC_DONE)); ! 413: } ! 414: } ! 415: break; ! 416: ! 417: case WM_CLOSE: ! 418: case IDC_DONE: ! 419: { ! 420: char lpszFile[MAX_PATH]; ! 421: ! 422: if (bHelpActive && ! 423: GetHelpFileName (lpszFile)) ! 424: WinHelp (hDlg, lpszFile, HELP_QUIT, 0); ! 425: ! 426: // clean up and go away ! 427: LocalUnlock (hToken); LocalFree (hToken); ! 428: LocalUnlock (hHelp); LocalFree (hHelp); ! 429: LocalUnlock (hIssue); LocalFree (hIssue); ! 430: LocalUnlock (hSuggest); LocalFree (hSuggest); ! 431: LocalFree (hEditLine); ! 432: DestroyWindow (hDlg); ! 433: } ! 434: break; ! 435: ! 436: case IDC_OPTIONS: ! 437: { ! 438: DWORD dwOptions = dwPTFlags; ! 439: ! 440: // call dialog to start port process ! 441: if (DialogBoxParam (GetModuleHandle (NULL), ! 442: IDD_OPTIONSDLG, ! 443: hDlg, ! 444: OptionsDlgProc, ! 445: (LPARAM)&dwOptions)) ! 446: { ! 447: dwPTFlags = dwOptions; ! 448: ! 449: // if PT_IGNORETOKEN, call CheckString ! 450: if (dwOptions & PT_IGNORETOKEN) ! 451: { ! 452: CheckString (rIssue.lpszToken, dwPTFlags, NULL); ! 453: dwPTFlags ^= PT_IGNORETOKEN; ! 454: } ! 455: } ! 456: ! 457: } ! 458: break; ! 459: ! 460: case IDC_HELP: ! 461: { ! 462: char lpszFile[MAX_PATH]; ! 463: ! 464: if (bIsHelpFile && GetHelpFileName (lpszFile)) ! 465: { ! 466: WinHelp (hDlg, lpszFile, HELP_KEY, (DWORD)rIssue.lpszHelpStr); ! 467: bHelpActive = TRUE; ! 468: } ! 469: } ! 470: break; ! 471: ! 472: case IDC_RESTART: ! 473: iLineNo = 0; ! 474: rIssue.nPosToken = 0; ! 475: iStartPos = 0; ! 476: PostMessage (hDlg, WM_COMMAND, IDC_CONTINUE, 0); ! 477: break; ! 478: } ! 479: break; ! 480: ! 481: default: ! 482: bRet = FALSE; ! 483: break; ! 484: } ! 485: ! 486: // return (message was processed); ! 487: return bRet; ! 488: } ! 489: ! 490: ! 491: ! 492: ! 493: // background porting status dialog ! 494: BOOL WINAPI BkPortDlgProc ( ! 495: HWND hDlg, ! 496: UINT uMsg, ! 497: UINT uParam, ! 498: LONG lParam) ! 499: { ! 500: BOOL bRet = TRUE; ! 501: char szFileName[MAX_PATH]; ! 502: char szFilePath[MAX_PATH]; ! 503: static BKFILELIST *lpbkFiles; ! 504: static int iCurThread; ! 505: static BOOL bStarted = FALSE; ! 506: BKFILELIST *lpNode; ! 507: ! 508: switch (uMsg) ! 509: { ! 510: case WM_INITDIALOG: ! 511: { ! 512: HWND hIssues = GetDlgItem (hDlg, IDC_ISSUES); ! 513: HWND hLines = GetDlgItem (hDlg, IDC_LINES); ! 514: HWND hComplete = GetDlgItem (hDlg, IDC_COMPLETE); ! 515: ! 516: // set background icon to porttool background icon and start minimized ! 517: SetClassLong (hDlg, ! 518: GCL_HICON, ! 519: (LONG)LoadIcon (GetModuleHandle (NULL), IDBkPort)); ! 520: ! 521: lpbkFiles = NULL; ! 522: iCurThread = -1; ! 523: ! 524: // build list of files to port from lParam ! 525: if (lParam) ! 526: { ! 527: if (!BuildFileList ((char *)lParam, &lpbkFiles)) ! 528: { ! 529: lpbkFiles = NULL; ! 530: break; ! 531: } ! 532: } ! 533: ! 534: else ! 535: { ! 536: // get file from user first ! 537: *szFileName = 0; ! 538: *szFilePath = 0; ! 539: ! 540: GetFileName (hDlg, szFileName, szFilePath); ! 541: if (!BuildFileList (szFilePath, &lpbkFiles)) ! 542: { ! 543: lpbkFiles = NULL; ! 544: break; ! 545: } ! 546: } ! 547: ! 548: lpNode = lpbkFiles; ! 549: // initialize each file in list ! 550: while (lpNode) ! 551: { ! 552: // add filename to listbox ! 553: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 554: LB_ADDSTRING, ! 555: 0, ! 556: (LPARAM)lpNode->bkFile.szFile); ! 557: ! 558: // initialize some stuff ! 559: lpNode->bkFile.hDlg = hDlg; ! 560: lpNode->bkFile.dwPTFlags = PT_DEFAULT; ! 561: ! 562: // start background thread on each file ! 563: StartBkPortThread (&lpNode->bkFile); ! 564: ! 565: // traverse list ! 566: lpNode = lpNode->Next; ! 567: } ! 568: ! 569: // select first thread in listbox ! 570: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), LB_SETCURSEL, 0, 0); ! 571: SetDlgItemText (hDlg, IDC_FILEPATH, lpbkFiles->bkFile.szFilePath); ! 572: ! 573: // if started with /b switch ! 574: if (!GetParent (hDlg)) ! 575: ShowWindow (hDlg, SW_SHOWMINIMIZED); ! 576: else ! 577: SetEvent (lpbkFiles->hEvents[BKPORT_STATUS]); ! 578: ! 579: iCurThread = 0; ! 580: bStarted = TRUE; ! 581: } ! 582: break; ! 583: ! 584: case WM_SHOWWINDOW: ! 585: if (bStarted) ! 586: { ! 587: int i = 0; ! 588: ! 589: lpNode = lpbkFiles; ! 590: while (i < iCurThread) ! 591: lpNode = lpNode->Next; ! 592: ! 593: if (!uParam) ! 594: ResetEvent (lpNode->hEvents[BKPORT_STATUS]); ! 595: else ! 596: SetEvent (lpNode->hEvents[BKPORT_STATUS]); ! 597: } ! 598: break; ! 599: ! 600: case WM_SIZE: ! 601: if (bStarted) ! 602: { ! 603: int i = 0; ! 604: ! 605: lpNode = lpbkFiles; ! 606: while (i < iCurThread) ! 607: lpNode = lpNode->Next; ! 608: ! 609: if (uParam == SIZEICONIC) ! 610: ResetEvent (lpNode->hEvents[BKPORT_STATUS]); ! 611: else ! 612: SetEvent (lpNode->hEvents[BKPORT_STATUS]); ! 613: } ! 614: break; ! 615: ! 616: case UM_STATUSUPDATE: ! 617: { ! 618: char Buff[10]; ! 619: ! 620: // update status info controls ! 621: SetDlgItemText (hDlg, IDC_ISSUES, itoa (LOWORD (uParam), Buff, 10)); ! 622: SetDlgItemText (hDlg, IDC_COMPLETE, itoa (HIWORD (uParam), Buff, 10)); ! 623: SetDlgItemText (hDlg, IDC_LINES, itoa (lParam, Buff, 10)); ! 624: } ! 625: break; ! 626: ! 627: case UM_THREADCOMPLETE: ! 628: { ! 629: int iThread = 0; ! 630: ! 631: // find handle in list ! 632: lpNode = lpbkFiles; ! 633: while (lpNode) ! 634: { ! 635: if ((HANDLE)uParam == lpNode->bkFile.hThread) ! 636: break; ! 637: lpNode = lpNode->Next; ! 638: iThread++; ! 639: } ! 640: ! 641: if (lpNode) ! 642: { ! 643: // remove file list item ! 644: RemoveFile (lpNode->bkFile.szFilePath, &lpbkFiles); ! 645: ! 646: // remove item from list box ! 647: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 648: LB_DELETESTRING, ! 649: iThread, ! 650: 0); ! 651: ! 652: // if current thread ended and more threads exist ! 653: if (iThread == iCurThread && ! 654: lpbkFiles && ! 655: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), LB_GETCOUNT, 0, 0)) ! 656: { ! 657: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), LB_SETCURSEL, 0, 0); ! 658: SetEvent (lpbkFiles->hEvents[BKPORT_STATUS]); ! 659: iCurThread = 0; ! 660: } ! 661: ! 662: else if (iThread == iCurThread) ! 663: { ! 664: iCurThread = -1; ! 665: PostMessage (hDlg, WM_COMMAND, IDC_BKDONE, 0); ! 666: } ! 667: ! 668: // clean up controls ! 669: SetDlgItemText (hDlg, IDC_FILEPATH, ""); ! 670: PostMessage (hDlg, UM_STATUSUPDATE, 0, 0); ! 671: } ! 672: ! 673: else ! 674: { ! 675: MessageBox (hDlg, ! 676: "Error, invalid thread handle process terminating.", ! 677: "Error", ! 678: MB_ICONSTOP | MB_OK); ! 679: ExitProcess (FALSE); ! 680: } ! 681: ! 682: } ! 683: break; ! 684: ! 685: case WM_COMMAND: ! 686: switch (LOWORD (uParam)) ! 687: { ! 688: case IDC_FILELIST: ! 689: // if new file selected change update signal to active thread ! 690: if (HIWORD (uParam) == LBN_SELCHANGE) ! 691: { ! 692: int i = 0; ! 693: int iNewThread = SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 694: LB_GETCURSEL, ! 695: 0, ! 696: 0); ! 697: ! 698: // reset current thread ! 699: lpNode = lpbkFiles; ! 700: while (lpNode) ! 701: { ! 702: if (i == iCurThread) ! 703: ResetEvent (lpNode->hEvents[BKPORT_STATUS]); ! 704: ! 705: if (i == iNewThread) ! 706: { ! 707: SetEvent (lpNode->hEvents[BKPORT_STATUS]); ! 708: SetDlgItemText (hDlg, ! 709: IDC_FILEPATH, ! 710: lpNode->bkFile.szFilePath); ! 711: } ! 712: ! 713: lpNode = lpNode->Next; ! 714: i++; ! 715: } ! 716: ! 717: iCurThread = iNewThread; ! 718: } ! 719: break; ! 720: ! 721: case IDC_ABORTFILE: ! 722: { ! 723: int i = 0; ! 724: HCURSOR hOldCursor; ! 725: ! 726: // reset current thread ! 727: lpNode = lpbkFiles; ! 728: while (lpNode) ! 729: { ! 730: if (i == iCurThread) ! 731: { ! 732: // put hourglass cursor up ! 733: hOldCursor = (HCURSOR)SetClassLong (hDlg, GCL_HCURSOR, NULL); ! 734: SetCursor (LoadCursor (NULL, IDC_WAIT)); ! 735: ! 736: // abort porting file where it is ! 737: SetEvent (lpNode->hEvents[BKPORT_ABORT]); ! 738: ! 739: // remove file from list when thread is dead ! 740: WaitForSingleObject (lpNode->bkFile.hThread, INFINITE); ! 741: RemoveFile (lpNode->bkFile.szFilePath, &lpbkFiles); ! 742: ! 743: // replace original cursor ! 744: SetClassLong (hDlg, GCL_HCURSOR, (LONG)hOldCursor); ! 745: SetCursor (hOldCursor); ! 746: ! 747: // update listbox ! 748: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 749: LB_DELETESTRING, ! 750: iCurThread, ! 751: 0); ! 752: ! 753: // select new event if any in listbox ! 754: if (SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 755: LB_GETCOUNT, ! 756: 0, ! 757: 0)) ! 758: { ! 759: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 760: LB_SETCURSEL, ! 761: 0, ! 762: 0); ! 763: SetEvent (lpbkFiles->hEvents[BKPORT_STATUS]); ! 764: iCurThread = 0; ! 765: } ! 766: ! 767: else ! 768: { ! 769: iCurThread = -1; ! 770: PostMessage (hDlg, WM_COMMAND, IDC_DONE, 0); ! 771: } ! 772: ! 773: // clean up controls ! 774: SetDlgItemText (hDlg, IDC_FILEPATH, ""); ! 775: PostMessage (hDlg, UM_STATUSUPDATE, 0, 0); ! 776: break; ! 777: } ! 778: ! 779: lpNode = lpNode->Next; ! 780: i++; ! 781: } ! 782: } ! 783: break; ! 784: ! 785: case IDC_ADDFILE: ! 786: { ! 787: // get file from user first ! 788: *szFileName = 0; ! 789: *szFilePath = 0; ! 790: ! 791: // add a file to the list ! 792: if (GetFileName (hDlg, szFileName, szFilePath)) ! 793: { ! 794: // if new list ! 795: if (!lpbkFiles) ! 796: BuildFileList (szFilePath, &lpbkFiles); ! 797: ! 798: else if (!AddFile (szFilePath, szFileName, lpbkFiles)) ! 799: break; ! 800: ! 801: // find node in list ! 802: lpNode = lpbkFiles; ! 803: while (lpNode) ! 804: { ! 805: if (!strcmp (lpNode->bkFile.szFilePath, szFilePath)) ! 806: break; ! 807: lpNode = lpNode->Next; ! 808: } ! 809: ! 810: if (lpNode) ! 811: { ! 812: // add filename to listbox ! 813: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 814: LB_ADDSTRING, ! 815: 0, ! 816: (LPARAM)lpNode->bkFile.szFile); ! 817: ! 818: // initialize some stuff ! 819: lpNode->bkFile.hDlg = hDlg; ! 820: lpNode->bkFile.dwPTFlags = PT_DEFAULT; ! 821: ! 822: // start background thread on this file ! 823: StartBkPortThread (&lpNode->bkFile); ! 824: ! 825: // if first thread ! 826: if (iCurThread == -1 || ! 827: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 828: LB_GETCOUNT, 0, 0) == 1) ! 829: { ! 830: iCurThread = 0; ! 831: SendMessage (GetDlgItem (hDlg, IDC_FILELIST), ! 832: LB_SETCURSEL, ! 833: 0, ! 834: 0); ! 835: SendMessage (hDlg, ! 836: WM_COMMAND, ! 837: MAKELONG (IDC_FILELIST, LBN_SELCHANGE), ! 838: 0); ! 839: } ! 840: } ! 841: } ! 842: } ! 843: break; ! 844: ! 845: case IDC_CHANGEOPTIONS: ! 846: { ! 847: DWORD dwFlags; ! 848: ! 849: dwFlags = (dwFlags & ~PT_IGNORECASE) ^ ! 850: (IsDlgButtonChecked (hDlg, IDC_BKIGNORECASE) ? PT_IGNORECASE : 0); ! 851: dwFlags = (dwFlags & ~PT_NOAPIS) ^ ! 852: (IsDlgButtonChecked (hDlg, IDC_BKNOAPIS) ? PT_NOAPIS : 0); ! 853: dwFlags = (dwFlags & ~PT_NOMESSAGES) ^ ! 854: (IsDlgButtonChecked (hDlg, IDC_BKNOMESSAGES) ? PT_NOMESSAGES : 0); ! 855: dwFlags = (dwFlags & ~PT_NOSTRUCTURES) ^ ! 856: (IsDlgButtonChecked (hDlg, IDC_BKNOSTRUCTURES) ? PT_NOSTRUCTURES : 0); ! 857: dwFlags = (dwFlags & ~PT_NOMACROS) ^ ! 858: (IsDlgButtonChecked (hDlg, IDC_BKNOMACROS) ? PT_NOMACROS : 0); ! 859: dwFlags = (dwFlags & ~PT_NOCONSTANTS) ^ ! 860: (IsDlgButtonChecked (hDlg, IDC_BKNOCONSTANTS) ? PT_NOCONSTANTS : 0); ! 861: dwFlags = (dwFlags & ~PT_NOTYPES) ^ ! 862: (IsDlgButtonChecked (hDlg, IDC_BKNOTYPES) ? PT_NOTYPES : 0); ! 863: dwFlags = (dwFlags & ~PT_NOCUSTOM) ^ ! 864: (IsDlgButtonChecked (hDlg, IDC_BKNOCUSTOM) ? PT_NOCUSTOM : 0); ! 865: ! 866: // change the options for the file being ported ! 867: lpbkFiles->bkFile.dwPTFlags = dwFlags; ! 868: } ! 869: break; ! 870: ! 871: case IDCANCEL: ! 872: { ! 873: HCURSOR hOldCursor; ! 874: HANDLE hThreads[MAXBKTHREADS]; ! 875: int i = 0; ! 876: ! 877: // put up confirm message ! 878: if (MessageBox (hDlg, ! 879: "Cancel background process?", ! 880: "PortTool - Abort", ! 881: MB_ICONQUESTION | MB_OKCANCEL) == IDOK) ! 882: { ! 883: // put hourglass cursor up ! 884: hOldCursor = (HCURSOR)SetClassLong (hDlg, GCL_HCURSOR, NULL); ! 885: SetCursor (LoadCursor (NULL, IDC_WAIT)); ! 886: ! 887: // if any files in list ! 888: if (lpbkFiles) ! 889: { ! 890: // abort all background threads and build thread handle array ! 891: lpNode = lpbkFiles; ! 892: while (lpNode) ! 893: { ! 894: SetEvent (lpNode->hEvents[BKPORT_ABORT]); ! 895: hThreads[i++] = lpNode->bkFile.hThread; ! 896: lpNode = lpNode->Next; ! 897: } ! 898: ! 899: // wait on completion of background threads ! 900: WaitForMultipleObjects (i, hThreads, TRUE, INFINITE); ! 901: ! 902: // free background port resources ! 903: FreeFileList (lpbkFiles); ! 904: } ! 905: ! 906: SetClassLong (hDlg, GCL_HCURSOR, (LONG)hOldCursor); ! 907: SetCursor (hOldCursor); ! 908: DestroyWindow (hDlg); ! 909: } ! 910: } ! 911: break; ! 912: ! 913: case IDC_BKDONE: ! 914: // if file list post message to cancel ! 915: if (lpbkFiles) ! 916: PostMessage (hDlg, WM_COMMAND, IDCANCEL, 0); ! 917: else ! 918: DestroyWindow (hDlg); ! 919: break; ! 920: ! 921: default: ! 922: bRet = FALSE; ! 923: break; ! 924: } ! 925: break; ! 926: ! 927: case WM_DESTROY: ! 928: // if no parent, post quit message ! 929: if (GetParent (hDlg) == NULL) ! 930: PostQuitMessage (1); ! 931: break; ! 932: ! 933: default: ! 934: bRet = FALSE; ! 935: break; ! 936: } ! 937: ! 938: return bRet; ! 939: } ! 940: ! 941: ! 942: ! 943: // funtion retrieves the help filename from the ini file ! 944: BOOL WINAPI GetHelpFileName ( ! 945: char *lpszFile) ! 946: { ! 947: char szAppName[30]; ! 948: char szWinHelp[30]; ! 949: char szDefault[] = "Default"; ! 950: char szIniFile[MAX_PATH]; ! 951: OFSTRUCT of; ! 952: ! 953: // get ini file and path ! 954: GetIniFile (szIniFile); ! 955: ! 956: // get help filename from ini file ! 957: LoadString (GetModuleHandle (NULL), IDS_APPNAME, szAppName, 30); ! 958: LoadString (GetModuleHandle (NULL), IDS_WINHELP, szWinHelp, 30); ! 959: GetPrivateProfileString (szAppName, ! 960: szWinHelp, ! 961: szDefault, ! 962: lpszFile, ! 963: MAX_PATH, ! 964: szIniFile); ! 965: ! 966: // test to see if help file exists ! 967: return (OpenFile (lpszFile, &of, OF_EXIST) != -1); ! 968: } ! 969: ! 970: ! 971: ! 972: ! 973: // rearrange dialog and controls ! 974: void WINAPI GrowDialog ( ! 975: HWND hDlg, ! 976: BOOL bBigger) ! 977: { ! 978: RECT rc; ! 979: int nChange = (bBigger ? DLGOFFSET : -DLGOFFSET); ! 980: ! 981: // grow main dialog ! 982: GetWindowRect (hDlg, &rc); ! 983: SetWindowPos (hDlg, ! 984: NULL, ! 985: rc.left, ! 986: rc.top, ! 987: rc.right-rc.left, ! 988: rc.bottom-rc.top + nChange, ! 989: SWP_NOMOVE | SWP_NOZORDER); ! 990: ! 991: // move stop button down ! 992: GetWindowRect (GetDlgItem (hDlg, IDCANCEL), &rc); ! 993: ScreenToClient (hDlg, (LPPOINT)&rc); ! 994: ScreenToClient (hDlg, (LPPOINT)&rc.right); ! 995: SetWindowPos (GetDlgItem (hDlg, IDCANCEL), ! 996: NULL, ! 997: rc.left, ! 998: rc.top + nChange, ! 999: rc.right-rc.left, ! 1000: rc.bottom-rc.top, ! 1001: SWP_NOSIZE | SWP_NOZORDER); ! 1002: ! 1003: // move CONTINUE button down ! 1004: GetWindowRect (GetDlgItem (hDlg, IDC_CONTINUE), &rc); ! 1005: ScreenToClient (hDlg, (LPPOINT)&rc); ! 1006: ScreenToClient (hDlg, (LPPOINT)&rc.right); ! 1007: SetWindowPos (GetDlgItem (hDlg, IDC_CONTINUE), ! 1008: NULL, ! 1009: rc.left, ! 1010: rc.top + nChange, ! 1011: rc.right-rc.left, ! 1012: rc.bottom-rc.top, ! 1013: SWP_NOSIZE | SWP_NOZORDER); ! 1014: ! 1015: // move restart button down ! 1016: GetWindowRect (GetDlgItem (hDlg, IDC_RESTART), &rc); ! 1017: ScreenToClient (hDlg, (LPPOINT)&rc); ! 1018: ScreenToClient (hDlg, (LPPOINT)&rc.right); ! 1019: SetWindowPos (GetDlgItem (hDlg, IDC_RESTART), ! 1020: NULL, ! 1021: rc.left, ! 1022: rc.top + nChange, ! 1023: rc.right-rc.left, ! 1024: rc.bottom-rc.top, ! 1025: SWP_NOSIZE | SWP_NOZORDER); ! 1026: ! 1027: // move options button down ! 1028: GetWindowRect (GetDlgItem (hDlg, IDC_OPTIONS), &rc); ! 1029: ScreenToClient (hDlg, (LPPOINT)&rc); ! 1030: ScreenToClient (hDlg, (LPPOINT)&rc.right); ! 1031: SetWindowPos (GetDlgItem (hDlg, IDC_OPTIONS), ! 1032: NULL, ! 1033: rc.left, ! 1034: rc.top + nChange, ! 1035: rc.right-rc.left, ! 1036: rc.bottom-rc.top, ! 1037: SWP_NOSIZE | SWP_NOZORDER); ! 1038: ! 1039: // move help button down ! 1040: GetWindowRect (GetDlgItem (hDlg, IDC_HELP), &rc); ! 1041: ScreenToClient (hDlg, (LPPOINT)&rc); ! 1042: ScreenToClient (hDlg, (LPPOINT)&rc.right); ! 1043: SetWindowPos (GetDlgItem (hDlg, IDC_HELP), ! 1044: NULL, ! 1045: rc.left, ! 1046: rc.top + nChange, ! 1047: rc.right-rc.left, ! 1048: rc.bottom-rc.top, ! 1049: SWP_NOSIZE | SWP_NOZORDER); ! 1050: ! 1051: // move done button down ! 1052: GetWindowRect (GetDlgItem (hDlg, IDC_DONE), &rc); ! 1053: ScreenToClient (hDlg, (LPPOINT)&rc); ! 1054: ScreenToClient (hDlg, (LPPOINT)&rc.right); ! 1055: SetWindowPos (GetDlgItem (hDlg, IDC_DONE), ! 1056: NULL, ! 1057: rc.left, ! 1058: rc.top + nChange, ! 1059: rc.right-rc.left, ! 1060: rc.bottom-rc.top, ! 1061: SWP_NOSIZE | SWP_NOZORDER); ! 1062: ! 1063: // show suggestion edit control and label when appropriate ! 1064: ShowWindow (GetDlgItem (hDlg, IDC_SUGGESTION), (bBigger ? SW_SHOW : SW_HIDE)); ! 1065: ShowWindow (GetDlgItem (hDlg, IDC_SUGGESTLABEL), (bBigger ? SW_SHOW : SW_HIDE)); ! 1066: } ! 1067: ! 1068: ! 1069: ! 1070: ! 1071: BOOL WINAPI BuildFileList ( ! 1072: char *lpFileList, ! 1073: LPBKFILELIST *lpList) ! 1074: { ! 1075: char *lpFile; ! 1076: char szFilePath[MAX_PATH]; ! 1077: char szFile[MAX_PATH]; ! 1078: HFILE hFile; ! 1079: OFSTRUCT of; ! 1080: BOOL bList = FALSE; ! 1081: ! 1082: // create heap for up to 50 files at a time ! 1083: if (!(hBkFileHeap = HeapCreate (HEAP_SERIALIZE, ! 1084: sizeof (BKFILELIST), ! 1085: MAXBKTHREADS * sizeof (BKFILELIST)))) ! 1086: return FALSE; ! 1087: ! 1088: // allocate first node in list ! 1089: *lpList = (BKFILELIST *)HeapAlloc (hBkFileHeap, sizeof (BKFILELIST)); ! 1090: (*lpList)->hEvents[BKPORT_ABORT] = NULL; ! 1091: ! 1092: // parse first file in list ! 1093: lpFile = strtok (lpFileList, " "); ! 1094: ! 1095: // loop through all files in list ! 1096: while (lpFile) ! 1097: { ! 1098: strcpy (szFilePath, lpFile); ! 1099: ! 1100: // if no path, add current directory as path ! 1101: if (!GetFileFromPath (szFilePath, szFile)) ! 1102: { ! 1103: strcpy (szFile, szFilePath); ! 1104: GetCurrentDirectory (MAX_PATH, szFilePath); ! 1105: strcat (szFilePath, "\\"); ! 1106: strcat (szFilePath, szFile); ! 1107: } ! 1108: ! 1109: // verify file is available ! 1110: hFile = OpenFile (szFilePath, &of, OF_READWRITE); ! 1111: if (hFile != -1) ! 1112: { ! 1113: // added at least one file ! 1114: bList = TRUE; ! 1115: ! 1116: // close file ! 1117: CloseHandle ((HANDLE)hFile); ! 1118: ! 1119: // add file to list ! 1120: AddFile (szFilePath, szFile, *lpList); ! 1121: } ! 1122: ! 1123: // get next file in list ! 1124: lpFile = strtok (NULL, " "); ! 1125: } ! 1126: ! 1127: // if no valid files, cleanup ! 1128: if (!bList) ! 1129: { ! 1130: HeapDestroy (hBkFileHeap); ! 1131: return FALSE; ! 1132: } ! 1133: ! 1134: return TRUE; ! 1135: } ! 1136: ! 1137: ! 1138: ! 1139: ! 1140: BOOL WINAPI AddFile ( ! 1141: char *lpFilePath, ! 1142: char *lpFile, ! 1143: BKFILELIST *lpbkFiles) ! 1144: { ! 1145: BKFILELIST *lpNode; ! 1146: ! 1147: ! 1148: // if first item in list don't need to allocate ! 1149: if (!lpbkFiles->hEvents[BKPORT_ABORT]) ! 1150: lpNode = lpbkFiles; ! 1151: else ! 1152: { ! 1153: lpNode = (BKFILELIST *)HeapAlloc (hBkFileHeap, sizeof (BKFILELIST)); ! 1154: if (!lpNode) ! 1155: return FALSE; ! 1156: ! 1157: // find end of list then add new node ! 1158: while (lpbkFiles->Next) ! 1159: lpbkFiles = lpbkFiles->Next; ! 1160: lpbkFiles->Next = lpNode; ! 1161: } ! 1162: ! 1163: // initialize node structure ! 1164: strcpy (lpNode->bkFile.szFile, lpFile); ! 1165: strcpy (lpNode->bkFile.szFilePath, lpFilePath); ! 1166: CreateEvents (lpNode->hEvents, &lpNode->bkFile); ! 1167: lpNode->Next = NULL; ! 1168: ! 1169: return TRUE; ! 1170: } ! 1171: ! 1172: ! 1173: ! 1174: ! 1175: BOOL WINAPI RemoveFile ( ! 1176: char *lpFilePath, ! 1177: LPBKFILELIST *lpbkFiles) ! 1178: { ! 1179: BKFILELIST *pHead = *lpbkFiles; ! 1180: BKFILELIST *pTail = *lpbkFiles; ! 1181: ! 1182: // loop thru list until file name matches ! 1183: while (pHead) ! 1184: { ! 1185: if (!strcmp (lpFilePath, pHead->bkFile.szFilePath)) ! 1186: { ! 1187: // special case remove first node ! 1188: if (pTail == pHead) ! 1189: { ! 1190: *lpbkFiles = pHead->Next; ! 1191: DestroyEvents (pHead->hEvents); ! 1192: HeapFree (hBkFileHeap, (char *)(pHead)); ! 1193: ! 1194: // if no more nodes, destroy heap ! 1195: if (!*lpbkFiles) ! 1196: HeapDestroy (hBkFileHeap); ! 1197: } ! 1198: ! 1199: else ! 1200: { ! 1201: pTail->Next = pHead->Next; ! 1202: DestroyEvents (pHead->hEvents); ! 1203: HeapFree (hBkFileHeap, (char *)pHead); ! 1204: } ! 1205: ! 1206: return TRUE; ! 1207: } ! 1208: ! 1209: pTail = pHead; ! 1210: pHead = pHead->Next; ! 1211: } ! 1212: ! 1213: return FALSE; ! 1214: } ! 1215: ! 1216: ! 1217: ! 1218: ! 1219: BOOL WINAPI FreeFileList ( ! 1220: BKFILELIST *lpbkFiles) ! 1221: { ! 1222: // loop thru each list item ! 1223: while (lpbkFiles) ! 1224: { ! 1225: // destroy event handles ! 1226: DestroyEvents (lpbkFiles->hEvents); ! 1227: ! 1228: lpbkFiles = lpbkFiles->Next; ! 1229: } ! 1230: ! 1231: // release entire heap ! 1232: HeapDestroy (hBkFileHeap); ! 1233: ! 1234: return TRUE; ! 1235: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.