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.

103 lines
2.2 KiB

  1. /*
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. */
  4. #include "sdppch.h"
  5. #include "sdpgen.h"
  6. #include "sdpver.h"
  7. // maximum value in a ushort variable
  8. const USHORT USHORT_MAX = -1;
  9. // no transition table for the base class
  10. // no need to set the start state as the parse engine is not used
  11. SDP_VERSION::SDP_VERSION(
  12. )
  13. : SDP_VALUE(SDP_INVALID_VERSION_FIELD, VERSION_STRING)
  14. {
  15. }
  16. void
  17. SDP_VERSION::InternalReset(
  18. )
  19. {
  20. m_Version.Reset();
  21. }
  22. BOOL
  23. SDP_VERSION::InternalParseLine(
  24. IN OUT CHAR *&Line
  25. )
  26. {
  27. CHAR SeparatorChar = '\0';
  28. // identify the token. if one of the the separator characters is found, replace
  29. // it by EOS and return the separator char. if none of the separator characters are
  30. // found, return NULL (ex. if EOS found first, return NULL)
  31. CHAR *Token = GetToken(Line, 1, NEWLINE_STRING, SeparatorChar);
  32. // when the block goes out of scope,
  33. // set the EOS character to the token separator character
  34. LINE_TERMINATOR LineTerminator(Token, SeparatorChar);
  35. // if there is no such token
  36. if ( !LineTerminator.IsLegal() )
  37. {
  38. SetLastError(m_ErrorCode);
  39. return FALSE;
  40. }
  41. // advance the line to the start of the next token
  42. Line += (LineTerminator.GetLength() + 1);
  43. // get the session id decimal value
  44. if ( !m_Version.ParseToken(Token) )
  45. {
  46. SetLastError(SDP_INVALID_VERSION_FIELD);
  47. return FALSE;
  48. }
  49. // check if the value is legal
  50. if ( (USHORT_MAX == m_Version.GetValue()) ||
  51. (CURRENT_SDP_VERSION < m_Version.GetValue()) )
  52. {
  53. SetLastError(SDP_INVALID_VERSION_FIELD);
  54. return FALSE;
  55. }
  56. INT_PTR Index;
  57. // fill in the field and separator char arrays
  58. try
  59. {
  60. Index = m_SeparatorCharArray.Add(CHAR_NEWLINE);
  61. }
  62. catch(...)
  63. {
  64. SetLastError(ERROR_OUTOFMEMORY);
  65. return FALSE;
  66. }
  67. try
  68. {
  69. m_FieldArray.Add(&m_Version);
  70. }
  71. catch(...)
  72. {
  73. m_SeparatorCharArray.RemoveAt(Index);
  74. SetLastError(ERROR_OUTOFMEMORY);
  75. return FALSE;
  76. }
  77. return TRUE;
  78. }