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.

146 lines
3.9 KiB

  1. //
  2. // Microsoft Corporation - Copyright 1997
  3. //
  4. //
  5. // TEXTPARS.CPP - Parses text/plain submissions
  6. //
  7. #include "pch.h"
  8. //
  9. // Constructor / Destructor
  10. //
  11. CTextPlainParse::CTextPlainParse(
  12. LPECB lpEcb,
  13. LPSTR *lppszOut,
  14. LPSTR *lpszDebug,
  15. LPDUMPTABLE lpDT )
  16. :CBase( lpEcb, lppszOut, lpszDebug, lpDT )
  17. {
  18. DebugMsg( lpszOut, g_cszTableHeader, "<BR>\
  19. (NOTE: To turn on detailed debugging information, add '?debug' to the end of action URL in the orginating HTML file.)\
  20. <br>\
  21. <H2>Text/Plain Form Data (METHOD=POST, ENCTYPE=TEXT/PLAIN)</H2>\
  22. ",
  23. "TBLMULTIFORM" );
  24. } // CTextPlainParse( )
  25. CTextPlainParse::~CTextPlainParse( )
  26. {
  27. } // ~CTextPlainParse( )
  28. CTextPlainParse::Parse( LPBYTE lpbData, LPDWORD lpdwParsed )
  29. {
  30. BOOL fReturn = TRUE;
  31. TraceMsg( TF_FUNC | TF_PARSE, "Parse()" );
  32. _lpbParse = _lpbData = lpbData;
  33. while ( (DWORD)(_lpbParse - _lpbData) < lpEcb->cbTotalBytes )
  34. {
  35. LPSTR lpszName = NULL; // points to the "name" field
  36. LPSTR lpszValue = NULL; // points to the "value" field
  37. LPSTR lpszEqual = NULL; // points to the "=" sign
  38. CHAR cTmp;
  39. lpszName = (LPSTR) _lpbParse;
  40. while (( *_lpbParse != '='
  41. && (DWORD)(_lpbParse - _lpbData) < lpEcb->cbTotalBytes ))
  42. _lpbParse++;
  43. if ( *_lpbParse != '=' )
  44. {
  45. DebugMsg( lpszDebug, "Expected to find an '=' after %u (0x%x) bytes.",
  46. (LPBYTE)lpszName - _lpbData, (LPBYTE)lpszName - _lpbData );
  47. fReturn = FALSE;
  48. goto Cleanup;
  49. }
  50. lpszEqual = (LPSTR) _lpbParse;
  51. *lpszEqual = 0; // terminate (save)
  52. _lpbParse++; // move past
  53. lpszValue = (LPSTR) _lpbParse;
  54. while (( *_lpbParse != '\r'
  55. && *_lpbParse != '\n'
  56. && (DWORD)(_lpbParse - _lpbData) < lpEcb->cbTotalBytes ))
  57. _lpbParse++;
  58. if (( *_lpbParse != '\r' ) && ( *_lpbParse != '\n' ))
  59. {
  60. DebugMsg( lpszDebug, "Expected to find a CR, LF, CRLF or LFCR after %u (0x%x) bytes.",
  61. (LPBYTE)lpszValue - _lpbData, (LPBYTE)lpszValue - _lpbData );
  62. fReturn = FALSE;
  63. goto Cleanup;
  64. }
  65. cTmp = *_lpbParse; // save
  66. *_lpbParse = 0; // terminate
  67. DebugMsg( lpszOut, "<TR ID=TR%s><TD ID=TD%s>%s</TD><TD ID=%s>%s</TD></TR>",
  68. lpszName, lpszName, lpszName, lpszName, lpszValue );
  69. *_lpbParse = cTmp; // restore
  70. *lpszEqual = '='; // restore
  71. _lpbParse++; // move past
  72. // A possible combination of CR, LF, CRLF or LFCR are acceptable.
  73. if (( *_lpbParse = '\r' ) || ( *_lpbParse = '\n' ))
  74. {
  75. _lpbParse++; // move past
  76. }
  77. }
  78. DebugMsg( lpszDebug, "Parsed %u (0x%x) bytes.", ( _lpbParse - _lpbData ), ( _lpbParse - _lpbData ) );
  79. Cleanup:
  80. // End table output
  81. StrCat( lpszOut, g_cszTableEnd );
  82. *lpdwParsed = _lpbParse - _lpbData;
  83. // indicates EOTable, this will be an empty table for text/plain
  84. lpDT[ 0 ].lpAddr = NULL;
  85. TraceMsg( TF_FUNC | TF_PARSE, "Parse() Exit = %s",
  86. BOOLTOSTRING( fReturn ) );
  87. return fReturn;
  88. } // Parse()
  89. /*****************************************************************************
  90. //
  91. // FUNCTION TEMPLATE
  92. //
  93. // ***************************************************************************
  94. //
  95. // What:
  96. //
  97. // Desc:
  98. //
  99. // In:
  100. //
  101. // Out:
  102. //
  103. // Return:
  104. //
  105. BOOL CTextPlainParse::( )
  106. {
  107. BOOL fReturn = TRUE;
  108. TraceMsg( TF_FUNC | TF_PARSE, "()" );
  109. TraceMsg( TF_FUNC | TF_PARSE, "() Exit = %s",
  110. BOOLTOSTRING( fReturn ) );
  111. return fReturn;
  112. } // ( )
  113. ******************************************************************************/