Leaked source code of windows server 2003
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.

120 lines
3.2 KiB

  1. /*++
  2. Copyright (c) 1992-1997 Microsoft Corporation
  3. Module Name:
  4. args.c
  5. Abstract:
  6. Contains routines for processing command line arguments.
  7. Environment:
  8. User Mode - Win32
  9. Revision History:
  10. 10-Feb-1997 DonRyan
  11. Rewrote to implement SNMPv2 support.
  12. --*/
  13. ///////////////////////////////////////////////////////////////////////////////
  14. // //
  15. // Include files //
  16. // //
  17. ///////////////////////////////////////////////////////////////////////////////
  18. #include "globals.h"
  19. #include "args.h"
  20. #include "stdlib.h"
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // //
  23. // Public procedures //
  24. // //
  25. ///////////////////////////////////////////////////////////////////////////////
  26. BOOL
  27. ProcessArguments(
  28. DWORD NumberOfArgs,
  29. LPSTR ArgumentPtrs[]
  30. )
  31. /*++
  32. Routine Description:
  33. Processes command line arguments.
  34. Arguments:
  35. NumberOfArgs - number of command line arguments.
  36. ArgumentPtrs - array of pointers to arguments.
  37. Return Values:
  38. Returns true if successful.
  39. --*/
  40. {
  41. DWORD dwArgument;
  42. LPSTR pCurrentArg;
  43. // initialize logging arguments
  44. g_CmdLineArguments.nLogLevel = INVALID_ARGUMENT;
  45. g_CmdLineArguments.nLogType = INVALID_ARGUMENT;
  46. // initialize service controller argument
  47. g_CmdLineArguments.fBypassCtrlDispatcher = FALSE;
  48. // process arguments
  49. while (NumberOfArgs--) {
  50. // retrieve argument pointer
  51. pCurrentArg = ArgumentPtrs[NumberOfArgs];
  52. // make sure valid argument passed
  53. if (IS_ARGUMENT(pCurrentArg, LOGLEVEL)) {
  54. // convert string into dword argument
  55. dwArgument = DWORD_ARGUMENT(pCurrentArg, LOGLEVEL);
  56. // store in global argument structure
  57. g_CmdLineArguments.nLogLevel = dwArgument;
  58. // modify the level at which logging occurs
  59. SnmpSvcSetLogLevel(g_CmdLineArguments.nLogLevel);
  60. } else if (IS_ARGUMENT(pCurrentArg, LOGTYPE)) {
  61. // convert string into dword argument
  62. dwArgument = DWORD_ARGUMENT(pCurrentArg, LOGTYPE);
  63. // store in global argument structure
  64. g_CmdLineArguments.nLogType = dwArgument;
  65. // modify the log type used during logging
  66. SnmpSvcSetLogType(g_CmdLineArguments.nLogType);
  67. } else if (IS_ARGUMENT(pCurrentArg, DEBUG)) {
  68. // disable service controller when debugging
  69. g_CmdLineArguments.fBypassCtrlDispatcher = TRUE;
  70. } else if (NumberOfArgs) {
  71. SNMPDBG((
  72. SNMP_LOG_WARNING,
  73. "SNMP: SVC: Ignoring argument %s.\n",
  74. pCurrentArg
  75. ));
  76. }
  77. }
  78. return TRUE;
  79. }