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.

101 lines
2.5 KiB

  1. /*****************************************************************/
  2. /** Microsoft Windows for Workgroups **/
  3. /** Copyright (C) Microsoft Corp., 1991-1992 **/
  4. /*****************************************************************/
  5. /*
  6. strparty.cxx
  7. NLS/DBCS-aware string class: party support
  8. This file contains the implementation of the Party() and
  9. DonePartying() methods of NLS_STR, used for string operations
  10. outside the set supported by NLS_STR itself.
  11. FILE HISTORY:
  12. gregj 03/25/93 Created
  13. */
  14. #include "npcommon.h"
  15. extern "C"
  16. {
  17. #include <netlib.h>
  18. }
  19. #if defined(DEBUG)
  20. static const CHAR szFileName[] = __FILE__;
  21. #define _FILENAME_DEFINED_ONCE szFileName
  22. #endif
  23. #include <npassert.h>
  24. #include <npstring.h>
  25. /*******************************************************************
  26. NAME: NLS_STR::Party
  27. SYNOPSIS: Obtains read-write access to the string buffer, and
  28. disables standard member function access to the string.
  29. ENTRY: No parameters
  30. EXIT: Returns a pointer to the string, NULL if in an error state
  31. NOTES: Use Party() with care. Check your partying code to
  32. make sure it's DBCS-safe, doesn't overflow the string
  33. buffer, etc.
  34. Each Party() must be matched with a DonePartying() call.
  35. They cannot be nested. It's probably not a good idea
  36. to leave a string in the Party()ing state for long.
  37. HISTORY:
  38. gregj 03/25/93 Created
  39. ********************************************************************/
  40. CHAR *NLS_STR::Party()
  41. {
  42. if (QueryError())
  43. return NULL;
  44. ReportError( WN_ACCESS_DENIED ); // keep other folks out
  45. return _pchData; // OK, go party
  46. }
  47. /*******************************************************************
  48. NAME: NLS_STR::DonePartying
  49. SYNOPSIS: Releases read-write access to the string buffer, and
  50. re-enables standard member access.
  51. ENTRY: cchNew - new string length (may be omitted, in which
  52. case it's determined by strlenf())
  53. EXIT: No return value
  54. NOTES:
  55. HISTORY:
  56. gregj 03/25/93 Created
  57. lens 03/16/94 Don't let Party/DonePartying pairs lose hard allocation errors.
  58. ********************************************************************/
  59. VOID NLS_STR::DonePartying( INT cchNew )
  60. {
  61. _cchLen = cchNew; // store new length
  62. if (QueryError() == WN_ACCESS_DENIED ) {
  63. ReportError( WN_SUCCESS ); // standard members can access now
  64. }
  65. IncVers(); // all ISTRs are invalid now
  66. }
  67. VOID NLS_STR::DonePartying( VOID )
  68. {
  69. DonePartying( ::strlenf( _pchData ) );
  70. }