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.

59 lines
1.9 KiB

  1. /*
  2. * asecchia 7-21-98
  3. * Wrote it.
  4. *
  5. * These routines are designed to help in parsing debugger extensions.
  6. */
  7. #ifndef DBG_EXT_PARSE
  8. #define DBG_EXT_PARSE
  9. int parse_Tokenizer(char *cmdstr, char **tok);
  10. int parse_FindNonSwitch(char **tok, int ntok, int start=0);
  11. int parse_IsToken(char **tok, int tok_pos, char *chk);
  12. int parse_iIsToken(char **tok, int tok_pos, char *chk);
  13. int parse_FindToken(char **tok, int ntok, char *srchtok);
  14. int parse_iFindToken(char **tok, int ntok, char *srchtok);
  15. int parse_IsSwitch(char **tok, int tok_pos, char sw);
  16. int parse_iIsSwitch(char **tok, int tok_pos, char sw);
  17. int parse_FindSwitch(char **tok, int ntok, char sw);
  18. int parse_iFindSwitch(char **tok, int ntok, char sw);
  19. /*
  20. * Parse the arguments passed to the extension
  21. * Automatically handle the -? option
  22. */
  23. #define PARSE_ARGUMENTS(ext_label) \
  24. char tmp_args[200]; \
  25. char *tokens[40]; \
  26. int ntok, tok_pos; \
  27. strcpy(tmp_args, args); \
  28. ntok = parse_Tokenizer(tmp_args, tokens); \
  29. if(ntok>0) { \
  30. tok_pos=parse_FindSwitch(tokens, ntok, '?'); \
  31. if(tok_pos>=0) { \
  32. goto ext_label; \
  33. } \
  34. } \
  35. tok_pos=0
  36. /*
  37. * Parse the arguments assuming a required parameter
  38. * which is a pointer to be parsed with the expression
  39. * handler.
  40. */
  41. #define PARSE_POINTER(ext_label) \
  42. UINT_PTR arg; \
  43. PARSE_ARGUMENTS(ext_label); \
  44. if(ntok<1) {goto ext_label;} \
  45. tok_pos = parse_FindNonSwitch(tokens, ntok); \
  46. if(tok_pos==-1) {goto ext_label;} \
  47. arg = (UINT_PTR)GetExpression(tokens[tok_pos])
  48. #endif