Source code of Windows XP (NT5)
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.

147 lines
3.5 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (c) 1999 Microsoft Corporation
  4. //
  5. // File: commonlib.h
  6. //
  7. // Contents: Prototypes of functions used across binaries in SFP
  8. //
  9. //
  10. // History: AshishS Created 07/02/99
  11. //
  12. //----------------------------------------------------------------------------
  13. #ifndef _COMMON_LIB_H
  14. #define _COMMON_LIB_H
  15. // #include <sfp.h>
  16. PVOID SFPMemAlloc( DWORD dwBytesToAlloc );
  17. VOID SFPMemFree( PVOID pvMemPtr );
  18. #define SFP_SAFE_FREE(x) { if ( (x) ) { SFPMemFree(x); (x) = NULL; } }
  19. /*
  20. * Macro to get char index's other than Str[i]
  21. */
  22. #define CHARINDEX(str,i) ( *(CharIndex(str,i)) )
  23. #ifndef MAX_BUFFER
  24. #define MAX_BUFFER 1024
  25. #endif
  26. #if 0
  27. DWORD GetFileVersion(TCHAR * pszFile,
  28. INT64 * pFileVersion);
  29. BOOL DoesFileExist(TCHAR * pszFileName);
  30. BOOL DoesDirExist(TCHAR * pszFileName );
  31. LPSTR GetFileNameFromPathA(LPCSTR pszPath, int cchText);
  32. LPWSTR GetFileNameFromPathW(LPCWSTR pszPath, int cchText);
  33. #ifdef UNICODE
  34. #define GetFileNameFromPath GetFileNameFromPathW
  35. #else
  36. #define GetFileNameFromPath GetFileNameFromPathA
  37. #endif // !UNICODE
  38. WCHAR * SFPConvertToUnicode(CHAR * pszCatalogFile);
  39. TCHAR * SFPDuplicateString(TCHAR * pszString);
  40. CHAR * SFPConvertToANSI(WCHAR * pwszString, DWORD dwBytes);
  41. WCHAR * SFPDuplicateMemory(WCHAR * pwszString, DWORD dwBytes);
  42. INT64 MakeVersionFromString(TCHAR * pszVersion);
  43. #endif
  44. /*
  45. * Registry Functions
  46. */
  47. BOOL WriteRegKey(BYTE * pbRegValue,
  48. DWORD dwNumBytes,
  49. TCHAR * pszRegKey,
  50. TCHAR * pszRegValueName,
  51. DWORD dwRegType);
  52. BOOL ReadRegKeyOrCreate(BYTE * pbRegValue, // The value of the reg key will be
  53. // stored here
  54. DWORD * pdwNumBytes, // Pointer to DWORD conataining
  55. // the number of bytes in the above buffer - will be
  56. // set to actual bytes stored.
  57. TCHAR * pszRegKey, // Reg Key to be opened
  58. TCHAR * pszRegValueName, // Reg Value to query
  59. DWORD dwRegTypeExpected,
  60. BYTE * pbDefaultValue, // default value
  61. DWORD dwDefaultValueSize); // size of default value
  62. BOOL ReadRegKey(BYTE * pbRegValue, // The value of the reg key will be
  63. // stored here
  64. DWORD * pdwNumBytes, // Pointer to DWORD conataining
  65. // the number of bytes in the above buffer - will be
  66. // set to actual bytes stored.
  67. TCHAR * pszRegKey, // Reg Key to be opened
  68. TCHAR * pszRegValueName, // Reg Value to query
  69. DWORD dwRegTypeExpected);
  70. /*
  71. * MBCS Char Index function
  72. */
  73. LPTSTR CharIndex(LPTSTR pszStr, DWORD idwIndex);
  74. //Calculate the Real size of a MBCS String
  75. DWORD StringLengthBytes( LPTSTR pszStr );
  76. /*
  77. * String Functions
  78. */
  79. void TrimString( LPTSTR pszStr );
  80. BOOL BufStrCpy(LPTSTR pszBuf, LPTSTR pszSrc, LONG lBufSize);
  81. LONG GetLine(FILE *fl, LPTSTR pszBuf, LONG lMaxBuf);
  82. // gets a char delemited field
  83. LONG GetField(LPTSTR pszMain, LPTSTR pszInto, LONG lNum, TCHAR chSep);
  84. /*
  85. * Function to get the current locale
  86. */
  87. UINT GetCurrentCodePage();
  88. #if DEBUG
  89. void SfpLogToStateMgrWindow( LPTSTR szLogMsg );
  90. #else
  91. #define SfpLogToStateMgrWindow( msg )
  92. #endif
  93. BOOL
  94. ExpandShortNames(
  95. LPTSTR pFileName,
  96. DWORD cbFileName,
  97. LPTSTR LongName,
  98. DWORD cbLongName
  99. );
  100. #endif //_COMMON_LIB_H