int main ( int Argc, char *Argv[] ) /*++ Routine Description: Call the routine to parse the command-line options, then process each file to build dependencies. Arguments: Argc - Standard C main() argc. Argv - Standard C main() argv. Returns: 0 if successful nonzero otherwise --*/ { STRING_LIST *File; STRING_LIST ProcessedFiles; STRING_LIST *TempList; STATUS Status; INT8 *Cptr; INT8 TargetFileName[MAX_PATH]; SetUtilityName (UTILITY_NAME); // // Process the command-line arguments // Status = ProcessArgs (Argc, Argv); if (Status != STATUS_SUCCESS) { return STATUS_ERROR; } // // Go through the list of source files and process each. // memset (&ProcessedFiles, 0, sizeof (STRING_LIST)); File = mGlobals.SourceFiles; while (File != NULL) { // // Clear out our list of processed files // TempList = ProcessedFiles.Next; while (ProcessedFiles.Next != NULL) { TempList = ProcessedFiles.Next->Next; free (ProcessedFiles.Next->Str); free (ProcessedFiles.Next); ProcessedFiles.Next = TempList; } // // Replace filename extension with ".obj" if they did not // specifically specify the target file // if (mGlobals.TargetFileName[0] == 0) { strcpy (TargetFileName, File->Str); // // Find the .extension // for (Cptr = TargetFileName + strlen (TargetFileName) - 1; (*Cptr != '\\') && (Cptr > TargetFileName) && (*Cptr != '.'); Cptr-- ) ; if (Cptr == TargetFileName) { Error (NULL, 0, 0, File->Str, "could not locate extension in filename"); goto Finish; } // // Tack on the ".obj" // strcpy (Cptr, ".obj"); } else { // // Copy the target filename they specified // strcpy (TargetFileName, mGlobals.TargetFileName); } if (mGlobals.IsCl) { Status = ProcessClOutput (TargetFileName, File->Str, &ProcessedFiles); } else { Status = ProcessFile (TargetFileName, File->Str, START_NEST_DEPTH, &ProcessedFiles, SearchCurrentDir); } if (Status != STATUS_SUCCESS) { goto Finish; } File = File->Next; } Finish: // // Free up memory // FreeLists (); // // Free up our processed files list // TempList = ProcessedFiles.Next; while (ProcessedFiles.Next != NULL) { TempList = ProcessedFiles.Next->Next; free (ProcessedFiles.Next->Str); free (ProcessedFiles.Next); ProcessedFiles.Next = TempList; } // // Close our temp output file // if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) { fclose (mGlobals.OutFptr); } if (mGlobals.NeverFail) { return STATUS_SUCCESS; } if (mGlobals.OutFileName != NULL) { if (GetUtilityStatus () == STATUS_ERROR) { // // If any errors, then delete our temp output // Also try to delete target file to improve the incremental build // remove (mGlobals.TmpFileName); remove (TargetFileName); } else { // // Otherwise, rename temp file to output file // remove (mGlobals.OutFileName); rename (mGlobals.TmpFileName, mGlobals.OutFileName); } } return GetUtilityStatus (); }
INT_PTR CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { WORD wCode, wId; DWORD dwThreadId; switch(uMsg) { case WM_CLOSE: if(g_hScanProc) TerminateThread(g_hScanProc, 0); FreeLists(hwndDlg); FreeFonts(); EndDialog(hwndDlg, 0); break; case WM_COMMAND: wId = LOWORD(wParam); wCode = HIWORD(wParam); switch(wId) { case IDC_BROWSE: if(wCode == BN_CLICKED) GetFilename(hwndDlg); break; case IDC_SCAN: if(wCode == BN_CLICKED) g_hScanProc = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)ScanProc, hwndDlg, NULL, &dwThreadId); break; case IDC_FILENAME: if(wCode == EN_CHANGE) TestFile(hwndDlg); break; case IDC_VIEW: if(wCode == BN_CLICKED) ViewPointer(hwndDlg); break; case IDC_DEFAULT: if(wCode == BN_CLICKED) SetHotkey(GetDlgItem(hwndDlg, IDC_HOTKEYS), SET_DEFAULT); break; case IDC_UNBIND: if(wCode == BN_CLICKED) SetHotkey(GetDlgItem(hwndDlg, IDC_HOTKEYS), SET_UNBIND); break; case IDC_ASSIGN: if(wCode == BN_CLICKED) SetHotkey(GetDlgItem(hwndDlg, IDC_HOTKEYS), GetHotkey(hwndDlg)); break; case IDC_SETFIXED: if(wCode == BN_CLICKED) { if(SelectFont(hwndDlg, g_szFixedFont, &g_lFixedSize, &g_bFixedBold)) SetFixedWidthFont(hwndDlg, g_szFixedFont, g_lFixedSize, g_bFixedBold); } break; case IDC_SETPROPORTIONAL: if(wCode == BN_CLICKED) { if(SelectFont(hwndDlg, g_szProportionalFont, &g_lProportionalSize, &g_bProportionalBold)) SetProportionalFont(hwndDlg, g_szProportionalFont, g_lProportionalSize, g_bProportionalBold); } break; case IDC_SAVE: if(wCode == BN_CLICKED) SaveINI(hwndDlg); break; } break; case WM_INITDIALOG: Init(hwndDlg); break; default: return FALSE; break; } return TRUE; }