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.

156 lines
4.4 KiB

  1. //
  2. // Copyright (c) 1997-2001 Microsoft Corporation, All Rights Reserved
  3. //
  4. #ifndef ModuleInfo_state_t
  5. #define ModuleInfo_state_t unsigned char
  6. #endif
  7. #define YYNEWLINE 10
  8. // MKS LEX prototype scanner header
  9. // Copyright 1991 by Mortice Kern Systems Inc.
  10. // All rights reserved.
  11. // You can define YY_PRESERVE to get System V UNIX lex compatibility,
  12. // if you need to change ModuleInfotext[] in your user actions
  13. // This is quite a bit slower, though, so the default is without
  14. #include <stdio.h> // uses printf(), et cetera
  15. #include <stdarg.h> // uses va_list
  16. #include <stdlib.h> // uses exit()
  17. #include <string.h> // uses memmove()
  18. #ifdef LEX_WINDOWS
  19. // define, if not already defined
  20. // the flag YYEXIT, which will allow
  21. // graceful exits from ModuleInfolex()
  22. // without resorting to calling exit();
  23. #ifndef YYEXIT
  24. #define YYEXIT 1
  25. #endif // YYEXIT
  26. // include the windows specific prototypes, macros, etc
  27. #include <windows.h>
  28. // the following is the handle to the current
  29. // instance of a windows program. The user
  30. // program calling ModuleInfolex must supply this!
  31. extern HANDLE hInst;
  32. #endif /* LEX_WINDOWS */
  33. class ModuleInfo_scan {
  34. protected:
  35. #ifdef LEX_WINDOWS
  36. // protected member function for actual scanning
  37. int win_ModuleInfolex();
  38. #endif /* LEX_WINDOWS */
  39. ModuleInfo_state_t * state; // state buffer
  40. int size; // length of state buffer
  41. int mustfree; // set if space is allocated
  42. int ModuleInfo_end; // end of pushback
  43. int ModuleInfo_start; // start state
  44. int ModuleInfo_lastc; // previous char
  45. #ifdef YYEXIT
  46. int ModuleInfoLexFatal; // Lex Fatal Error Flag
  47. #endif // YYEXIT
  48. #ifndef YY_PRESERVE // efficient default push-back scheme
  49. char save; // saved ModuleInfotext[ModuleInfoleng]
  50. #else // slower push-back for ModuleInfotext mungers
  51. char *save; // saved ModuleInfotext[]
  52. char *push;
  53. #endif
  54. public:
  55. char *ModuleInfotext; // ModuleInfotext text buffer
  56. FILE *ModuleInfoin; // input stream
  57. FILE *ModuleInfoout; // output stream
  58. int ModuleInfolineno; // line number
  59. int ModuleInfoleng; // ModuleInfotext token length
  60. ModuleInfo_scan(int = 100); // constructor for this scanner
  61. // default token & pushback size is 100 bytes
  62. ModuleInfo_scan(int, char*, char*, ModuleInfo_state_t*);
  63. // constructor when tables are given
  64. ~ModuleInfo_scan(); // destructor
  65. int ModuleInfolex(); // begin a scan
  66. virtual int ModuleInfogetc() { // scanner source of input characters
  67. return getc(ModuleInfoin);
  68. }
  69. virtual int ModuleInfowrap() { return 1; } // EOF processing
  70. virtual void ModuleInfoerror(char *,...); // print error message
  71. virtual void output(int c) { putc(c, ModuleInfoout); }
  72. #ifdef YYEXIT
  73. virtual void YY_FATAL(char * msg) { // print message and set error flag
  74. ModuleInfoerror(msg); ModuleInfoLexFatal = 1;
  75. }
  76. #else // YYEXIT
  77. virtual void YY_FATAL(char * msg) { // print message and stop
  78. ModuleInfoerror(msg); exit(1);
  79. }
  80. #endif // YYEXIT
  81. virtual void ECHO() { // print matched input
  82. fputs((const char *) ModuleInfotext, ModuleInfoout);
  83. }
  84. int input(); // user-callable get-input
  85. int unput(int c); // user-callable unput character
  86. void ModuleInfo_reset(); // reset scanner
  87. void setinput(FILE * in) { // switch input streams
  88. ModuleInfoin = in;
  89. }
  90. void setoutput(FILE * out) { // switch output
  91. ModuleInfoout = out;
  92. }
  93. void NLSTATE() { ModuleInfo_lastc = YYNEWLINE; }
  94. void YY_INIT() {
  95. ModuleInfo_start = 0;
  96. ModuleInfoleng = ModuleInfo_end = 0;
  97. ModuleInfo_lastc = YYNEWLINE;
  98. }
  99. void YY_USER() { // set up ModuleInfotext for user
  100. #ifndef YY_PRESERVE
  101. save = ModuleInfotext[ModuleInfoleng];
  102. #else
  103. size_t n = ModuleInfo_end - ModuleInfoleng;
  104. push = save+size - n;
  105. if (n > 0)
  106. memmove(push, ModuleInfotext+ModuleInfoleng, n);
  107. #endif
  108. ModuleInfotext[ModuleInfoleng] = 0;
  109. }
  110. void YY_SCANNER() { // set up ModuleInfotext for scanner
  111. #ifndef YY_PRESERVE
  112. ModuleInfotext[ModuleInfoleng] = save;
  113. #else
  114. size_t n = save+size - push;
  115. if (n > 0)
  116. memmove(ModuleInfotext+ModuleInfoleng, push, n);
  117. ModuleInfo_end = ModuleInfoleng + n;
  118. #endif
  119. }
  120. void ModuleInfoless(int n) { // trim input to 'n' bytes
  121. if (n >= 0 && n <= ModuleInfo_end) {
  122. YY_SCANNER();
  123. ModuleInfoleng = n;
  124. YY_USER();
  125. }
  126. }
  127. void ModuleInfocomment(char *const mat); // skip comment input
  128. int ModuleInfomapch(int delim, int escape); // map C escapes
  129. } ;