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.

118 lines
3.1 KiB

  1. /*++
  2. Copyright (c) 1997 Microsoft Corporation
  3. Module Name:
  4. parsearg.h
  5. Abstract:
  6. Argument Handling
  7. Author:
  8. MikeTs
  9. Environment:
  10. Any
  11. Revision History:
  12. --*/
  13. #ifndef _PARSEARG_H_
  14. #define _PARSEARG_H_
  15. //
  16. // Error Codes
  17. //
  18. #define ARGERR_NONE 0
  19. #define ARGERR_UNKNOWN_SWITCH 1
  20. #define ARGERR_NO_SEPARATOR 2
  21. #define ARGERR_INVALID_NUM 3
  22. #define ARGERR_INVALID_TAIL 4
  23. //
  24. // Parsing options
  25. //
  26. #define DEF_SWITCHCHARS "/-"
  27. #define DEF_SEPARATORS ":="
  28. //
  29. // Argument types
  30. //
  31. #define AT_STRING 1
  32. #define AT_NUM 2
  33. #define AT_ENABLE 3
  34. #define AT_DISABLE 4
  35. #define AT_ACTION 5
  36. //
  37. // Parse flags
  38. //
  39. #define PF_NOI 0x0001 //No-Ignore-Case
  40. #define PF_SEPARATOR 0x0002 //parse for separator
  41. //
  42. // Type definitions
  43. //
  44. typedef struct _ARGTYPE ARGTYPE, *PARGTYPE;
  45. typedef int (*PFNARG)(char **, PARGTYPE);
  46. struct _ARGTYPE {
  47. UCHAR *ArgID; // argument ID string
  48. ULONG ArgType; // see argument types defined above
  49. ULONG ParseFlags; // see parse flags defined above
  50. VOID *ArgData; // ARG_STRING: (char **) - ptr to string ptr
  51. // ARG_NUM: (int *) - ptr to integer number
  52. // ARG_ENABLE: (unsigned *) - ptr to flags
  53. // ARG_DISABLE: (unsigned *) - ptr to flags
  54. // ARG_ACTION: ptr to function
  55. ULONG ArgParam; // ARG_STRING: none
  56. // ARG_NUM: base
  57. // ARG_ENABLE: flag bit mask
  58. // ARG_DISABLE: flag bit mask
  59. // ARG_ACTION: none
  60. PFNARG ArgVerify; // pointer to argument verification function
  61. // this will be ignored for ARG_ACTION
  62. };
  63. typedef struct _PROGINFO {
  64. UCHAR *SwitchChars; // if null, DEF_SWITCHCHARS is used
  65. UCHAR *Separators; // if null, DEF_SEPARATORS is used
  66. UCHAR *ProgPath; // ParseProgInfo set this ptr to prog. path
  67. UCHAR *ProgName; // ParseProgInfo set this ptr to prog. name
  68. } PROGINFO;
  69. typedef PROGINFO *PPROGINFO;
  70. ULONG
  71. ParseArgSwitch(
  72. PUCHAR *Argument,
  73. PARGTYPE ArgumentArray,
  74. PPROGINFO ProgramInfo
  75. );
  76. VOID
  77. ParseProgramInfo(
  78. PUCHAR ProgramName,
  79. PPROGINFO ProgramInfo
  80. );
  81. ULONG
  82. ParseSwitches(
  83. PULONG ArgumentCount,
  84. PUCHAR **ArgumentList,
  85. PARGTYPE ArgumentArray,
  86. PPROGINFO ProgramInfo
  87. );
  88. VOID
  89. PrintError(
  90. ULONG ErrorCode,
  91. PUCHAR Argument,
  92. PPROGINFO ProgramInfo
  93. );
  94. #endif