Counter Strike : Global Offensive Source Code
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.

55 lines
1.5 KiB

  1. //========= Copyright � 2005-2005, 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. // NOTE: This has to be the last file included!
  14. #include "tier0/memdbgon.h"
  15. static void PrintFReportHandler(char const *job_name, int total_units_to_do, int n_units_completed)
  16. {
  17. static bool work_in_progress=false;
  18. static char LastJobName[1024];
  19. if ( Q_strncmp( LastJobName, job_name, sizeof( LastJobName ) ) )
  20. {
  21. if ( work_in_progress )
  22. printf("..done\n");
  23. Q_strncpy( LastJobName, job_name, sizeof( LastJobName ) );
  24. }
  25. if ( (total_units_to_do > 0 ) && (total_units_to_do >= n_units_completed) )
  26. {
  27. int percent_done=(100*n_units_completed)/total_units_to_do;
  28. printf("\r%s : %d%%",LastJobName, percent_done );
  29. work_in_progress = true;
  30. }
  31. else
  32. {
  33. printf("%s\n",LastJobName);
  34. work_in_progress = false;
  35. }
  36. }
  37. void InitCommandLineProgram( int &argc, char ** &argv )
  38. {
  39. MathLib_Init( 1,1,1,0,false,true,true,true);
  40. CommandLine()->CreateCmdLine( argc, argv );
  41. InitDefaultFileSystem();
  42. InstallProgressReportHandler( PrintFReportHandler );
  43. // handle -allowdebug transparently
  44. if ( ( argc > 1 ) && ( !strcmp( argv[1], "-allowdebug" ) ) )
  45. {
  46. argv++; // messes up argv[0]
  47. argc--;
  48. }
  49. }