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.

67 lines
2.7 KiB

  1. /******************************Module*Header***********************************\
  2. *
  3. * *******************
  4. * * GDI SAMPLE CODE *
  5. * *******************
  6. *
  7. * Module Name: extparse.h
  8. *
  9. * Header fiel for all the token parser functions
  10. *
  11. * Copyright (C) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (C) 1995-1999 Microsoft Corporation. All rights reserved.
  13. ******************************************************************************/
  14. #ifndef __EXTPARSE__H__
  15. #define __EXTPARSE__H__
  16. int iParseTokenizer(char* pcCmdStr, char** ppcTok);
  17. int iParseFindNonSwitch(char** ppcTok, int iTok, int iStart = 0);
  18. int iParseIsToken(char **ppcTok, int iTokPos, char* pcChk);
  19. int iParseiIsToken(char **ppcTok, int iTokPos, char* pcChk);
  20. int iParseFindToken(char** ppcTok, int iTok, char* pcSrchTok);
  21. int iParseiFindToken(char** ppcTok, int iTok, char* pcSrchTok);
  22. int iParseIsSwitch(char** ppcTok, int iTokPos, char cSwitch);
  23. int iParseiIsSwitch(char** ppcTok, int iTokPos, char cSwitch);
  24. int iParseFindSwitch(char** ppcTok, int iTok, char cSwitch);
  25. int iParseiFindSwitch(char** ppcTok, int iTok, char cSwitch);
  26. /**********************************Public*Routine******************************\
  27. *
  28. * Parse the arguments passed to the extension
  29. * Automatically handle the -? option
  30. *
  31. ******************************************************************************/
  32. #define PARSE_ARGUMENTS(ext_label) \
  33. char tmp_args[200]; \
  34. char *tokens[40]; \
  35. int ntok, tok_pos; \
  36. strcpy(tmp_args, args); \
  37. ntok = iParseTokenizer(tmp_args, tokens); \
  38. if(ntok>0) { \
  39. tok_pos=iParseFindSwitch(tokens, ntok, '?'); \
  40. if(tok_pos>=0) { \
  41. goto ext_label; \
  42. } \
  43. } \
  44. tok_pos=0
  45. /**********************************Public*Routine******************************\
  46. *
  47. * Parse the arguments assuming a required parameter
  48. * which is a pointer to be parsed with the expression
  49. * handler.
  50. *
  51. ******************************************************************************/
  52. #define PARSE_POINTER(ext_label) \
  53. UINT_PTR arg; \
  54. PARSE_ARGUMENTS(ext_label); \
  55. if(ntok<1) {goto ext_label;} \
  56. tok_pos = iParseFindNonSwitch(tokens, ntok); \
  57. if(tok_pos==-1) {goto ext_label;} \
  58. arg = (UINT_PTR)GetExpression(tokens[tok_pos])
  59. #endif