Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: perform initialization needed in most command line programs
  4. //
  5. //===================================================================================-=//
  6. #include <tier0/platform.h>
  7. #include <tier2/tier2.h>
  8. #include <mathlib/mathlib.h>
  9. #include <tier0/icommandline.h>
  10. #include "tier0/memalloc.h"
  11. #include "tier0/progressbar.h"
  12. #include "tier1/strtools.h"
  13. static void PrintFReportHandler(char const *job_name, int total_units_to_do, int n_units_completed)
  14. {
  15. static bool work_in_progress=false;
  16. static char LastJobName[1024];
  17. if ( Q_strncmp( LastJobName, job_name, sizeof( LastJobName ) ) )
  18. {
  19. if ( work_in_progress )
  20. printf("..done\n");
  21. Q_strncpy( LastJobName, job_name, sizeof( LastJobName ) );
  22. }
  23. if ( (total_units_to_do > 0 ) && (total_units_to_do >= n_units_completed) )
  24. {
  25. int percent_done=(100*n_units_completed)/total_units_to_do;
  26. printf("\r%s : %d%%",LastJobName, percent_done );
  27. work_in_progress = true;
  28. }
  29. else
  30. {
  31. printf("%s\n",LastJobName);
  32. work_in_progress = false;
  33. }
  34. }
  35. void InitCommandLineProgram( int argc, char **argv )
  36. {
  37. MathLib_Init( 1,1,1,0,false,true,true,true);
  38. CommandLine()->CreateCmdLine( argc, argv );
  39. InitDefaultFileSystem();
  40. InstallProgressReportHandler( PrintFReportHandler );
  41. // By default, command line programs should not use the new assert dialog,
  42. // and any asserts should be fatal, unless we are being debugged
  43. if ( !Plat_IsInDebugSession() )
  44. SpewOutputFunc( DefaultSpewFuncAbortOnAsserts );
  45. }