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.

78 lines
2.9 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: extparse.hxx
  3. *
  4. * Copyright (c) 1998-2000 Microsoft Corporation
  5. *
  6. * asecchia 7-21-98
  7. * Wrote it.
  8. *
  9. * These routines are designed to help in parsing debugger extensions.
  10. *
  11. \**************************************************************************/
  12. #ifndef DBG_EXT_PARSE
  13. #define DBG_EXT_PARSE
  14. int parse_Tokenizer(char *cmdstr, char **tok);
  15. int parse_FindNonSwitch(char **tok, int ntok, int start=0);
  16. int parse_IsToken(char **tok, int tok_pos, char *chk);
  17. int parse_iIsToken(char **tok, int tok_pos, char *chk);
  18. int parse_FindToken(char **tok, int ntok, char *srchtok);
  19. int parse_iFindToken(char **tok, int ntok, char *srchtok);
  20. int parse_IsSwitch(char **tok, int tok_pos, char sw);
  21. int parse_iIsSwitch(char **tok, int tok_pos, char sw);
  22. int parse_FindSwitch(char **tok, int ntok, char sw);
  23. int parse_iFindSwitch(char **tok, int ntok, char sw);
  24. /*
  25. * Parse the arguments passed to the extension
  26. * Automatically handle the -? option
  27. */
  28. #define PARSE_ARGUMENTS(ext_label) \
  29. char tmp_args[200]; \
  30. char *tokens[40]; \
  31. int ntok, tok_pos; \
  32. strcpy(tmp_args, args); \
  33. ntok = parse_Tokenizer(tmp_args, tokens); \
  34. if(ntok>0) { \
  35. tok_pos=parse_FindSwitch(tokens, ntok, '?'); \
  36. if(tok_pos>=0) { \
  37. goto ext_label; \
  38. } \
  39. } \
  40. tok_pos=0
  41. /*
  42. * Parse the arguments assuming a required parameter
  43. * which is a pointer to be parsed with the expression
  44. * handler.
  45. */
  46. #define PARSE_POINTER(ext_label) \
  47. ULONG64 arg; \
  48. DEBUG_VALUE DbgValArg; \
  49. PARSE_ARGUMENTS(ext_label); \
  50. if (ntok < 1) { goto ext_label; } \
  51. tok_pos = parse_FindNonSwitch(tokens, ntok); \
  52. if (tok_pos == -1) { goto ext_label; } \
  53. if (ExtQuery(Client) != S_OK) { goto ext_label; } \
  54. if (g_pExtControl-> \
  55. Evaluate(tokens[tok_pos], \
  56. DEBUG_VALUE_INT64, \
  57. &DbgValArg, \
  58. NULL) == S_OK) \
  59. { \
  60. arg = DbgValArg.I64; \
  61. } \
  62. else \
  63. { \
  64. arg = 0; \
  65. } \
  66. ExtRelease()
  67. #endif